[jQuery] Hover event problems
Hi
I'm developing a basic gallery script for one of our clients, based on
code that was already working for this client. The only trouble is
that, for some reason, the hover events aren't binding in Firefox 3
(plus numerous extensions). They're being bound in IE7 (although the
code still isn't doing what we want!)
Here's the code...
HTML:
<div class="gallery left">
<div class="target"></div>
<ul>
<li><img src="thumb/image1.jpg" /></li>
<li><img src="thumb/image2.jpg" /></li>
<li><img src="thumb/image3.jpg" /></li>
</ul>
</div>
JavaScript:
$('.gallery li img').hover(gen_thumbnail_over, gen_thumbnail_out);
function gen_thumbnail_over() {
var gallery = $j(this).parent().parent().parent();
var target = $j(gallery).find('.target');
var target_img = $j(target).find('img');
$j(target_img).remove();
$j(target).append('<img src="' + $j(this).attr("src").replace(/
thumb\//i, "")
+ '" />');
$j(target_img).css("opacity", "0.0");
if($j(gallery).hasClass("left")) {
// left-hand animate settings
}
else if($j(gallery).hasClass("right")) {
// right-hand animate settings
}
}
function gen_thumbnail_out() {
var gallery = $j(this).parent().parent().parent();
var target = $j(gallery).find('.target');
var target_img = $j(target).find('img');
if($j(gallery).hasClass("left")) {
// left-hand animate settings
}
else if($j(gallery).hasClass("right")) {
// right-hand animate settings
}
}
Is there anything obvious that anyone can see that would prevent the
event binding in Firefox?
Thanks
Jon