Reputation: 20862
I have two events:
$('li').on({
'mouseover':fadeImgOut,
'mouseout' :fadeImgIn
});
and functions...
function fadeImgOut() {
$(this).find('img').animate({opacity:'.5'}, 1000);
}
function fadeImgIn() {
$(this).find('img').animate({opacity:'1'}, 1000);
}
When I hover on it, the image fadeout, fadein and fadeout
and when I'm moving the mouse out, the image fadein, fadeout and fadein
again.
I can't explain this behavior: why the image not fading-in on mouseover
and fading-out on mouseout
?
Upvotes: 0
Views: 96
Reputation: 388316
use
$('li').on({
'mouseenter':fadeImgOut,
'mouseleave' :fadeImgIn
});
Or better
$('li').hover(fadeImgOut, fadeImgIn)
Upvotes: 2