I have some divs that are created with data from a json string. Most of them are images. Over those dynamic loaded images and want to show a div when mouse over it and hide when you mouse out. Therefore I used the live function, found it here on the forum. The mouse over function works but it won't mouse out. So when I hover one image the div shows up but when I mouse out the div is still visible. Any suggestions on this?
My code
<script type="text/javascript">
$('.product').live("hover", function() {
$(this).find('.product').stop(false,true); // get the image where hovering
$(this).find('div.caption').stop(false,true).fadeIn(100); // and fade in
},
function() {
$(this).find('.product').stop(false,true); // on mouse leave hide it
$(this).find('div.caption').stop(false,true).fadeOut(100); // fade out
});
</script>
UPDATED ANSWER Thanks to the help below I found the solution.
$(".productsGrid .product").live("mouseenter", function() {$(this).find('.product').stop(false,true);
$(this).find('div.caption').stop(false,true).fadeIn(100);})
$(".productsGrid .product").live("mouseleave", function() { $(this).find('.product').stop(false,true);
$(this).find('div.caption').stop(false,true).fadeOut(100);});