PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 27, 2022

[FIXED] How do I trigger an event on mouse over with iframes

 October 27, 2022     javascript, jquery, jquery-events     No comments   

Issue

I have tried everything and cant get the value of the next iframe, the i frames are echoed out using PHP. (code below)

    <div class="video" vid="'.$userID.'" '.$style.'"><iframe vid="'.$userID.'" width="200" height="200" src="http://www.youtube.com/embed/'.$urlLink.'?autoplay=1&wmode=transparent" frameborder="0" allowfullscreen></iframe></div>

The video id is from the database. I currently have two videos and they both show different feeds so the src is working fine and the vid="" is set based on the users id, this is also changing each time correctly (I have verified this with inspect element).

The issue I'm having is trying to get the vid attr from the div to change on mouseenter. Using the code below I receive a popup but the video id is not changing. It is just alerting the first instance of the divs vid="" value.

I'm really stuck so any advise would be great.

$(document).on('mouseenter','div.video',function(e){

e.stopPropagation();

var videoID = jQuery('div.video').attr("vid");

 alert(videoID);

});

Solution

You're getting the value from the first element in the collection, as you're selecting all of them. To select just the hovered element use the this keyword :

$(document).on('mouseenter','.video',function(){
    var videoID = $(this).attr("vid");
    alert(videoID);
});


Answered By - adeneo
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing