开发者

Kill Event when hover off in Jquery

开发者 https://www.devze.com 2022-12-15 02:52 出处:网络
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

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

精彩评论

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