I have a jQuery issue I can't get past:
(function ($) {
var links = new Array();
var vidFrame = document.getElementById('videoFrame');
links = $('.video');
$(links).each(function() {
$(this).bind('mouseenter', function() {
$(vidFrame).attr('src',$(this).attr('href'));
window.frames[0].location.reload();
});
});
}(jQuery));
vidFrame
is an iframe, links is a collection of links that (right now) link back to some content. I'm trying to get the click event assigned to each link so that mousing over that link broadcasts its source video into the iframe. I want to leave the original link info in the a href so that if JavaScript is disabled, the links just take you to the content instead.
The window.frames
statement supposedly reloads the iframe but I haven't got far enough to test it.
The script gets the right href, it just doesn't bind it properly. I think the $(this)
statement is scoped correctly, I was logging to the console and getting the links I wanted, but for some reason the events don't bind?
This is an area I've had trouble with before, specifically mixing JavaScript and jQuery within the each()
loop. I'd really be into any insight.