开发者

Kill Event when hover off in Jquery

I've seen this somewhere before but I can't seem to find the little snippet.

If I have a div that sets opacity (or animates up) on hover, but I hover off that div before its done animating, I want it to toggle back. Otherwise I hover over it a few times and I have 10+ seconds of animation/flashing to wait for.

Here is my code:

$("a.prev").hover(function(){
   开发者_运维问答 $(this).fadeTo("normal", 0.6); 
},function(){
    $(this).fadeTo("normal", .1); 
});


Use stop():

$("a.prev").hover(function(){
    $(this).stop().fadeTo("normal", 0.6); 
},function(){
    $(this).stop().fadeTo("normal", .1); 
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜