I'm trying to create a function which will add an overlay to a thumbnail image when you hover over it and remove the overlay when you leave it. Here is my HTML...
<div class="thumb"><img src="i/testThumb.gif" /></div>
And here is my jQuery...
$('.thumb').live('mouseover', function(event){
if($(this).find('.overlay').length == 0){
$(this).prepend('<div class="overlay"></div>');
}
return false;
});
$('#galleryPanel .thumb').live('mouseout', function(event){
$(this).find('.overlay').remove();
return false;
});
The trouble is that when the overlay is created the mouse is already over it and that triggers the "mouseout" of the container, which removes the overlay, and it cycles continuously flashing on and off.
Is there an easy solution to this?