Jump to content

How to have multiple ids and return multiple elements

Recommended Posts

Hello, I have different overlay images on iframe vimeo videos. As I have several embeded vimeo videos and overlay images, I would like to add a script so that when I click on one overlay image it doesn't apply to all the overlay images on the page.

Here's the code, thanks


<!DOCTYPE html>

#vid {
  display: none;
  margin-top: -365px;

#vid2 {
  display: none;
  margin-top: -365px;

#iframe_id { pointer-events: none; }


<img src="https://www.ebnerfilm.com/wp-content/uploads/2019/08/LV_INTERVIEW_GIF_PLAY.gif" class="gliphy" onclick="myFunction()">
<div id="vid">
<iframe src="https://player.vimeo.com/video/353777739" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>


<img src="https://www.ebnerfilm.com/wp-content/uploads/2019/08/LOIS_LANE_GIF_PLAY.gif" class="gliphy" onclick="myFunction()">
<div id="vid2">
<iframe src="https://player.vimeo.com/video/196409842" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

function myFunction() {
  document.getElementById("vid").style.display = "block";
  document.getElementById("vid2").style.display = "block";
  $('#iframe_id_wrapper').click(function() {
    //run function that records clicks



Link to post
Share on other sites

IF the container div ALWAYS follow the clicked image you can use 'this' to represent  the element just clicked and '.nextElementSibling' to transverse to next element (div with id)


	function myFunction(elem) {
  elem.nextElementSibling.style.display = "block";
Edited by dsonesuk
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...