views:

509

answers:

1

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); 
});
+1  A: 

Use stop():

$("a.prev").hover(function(){
    $(this).stop().fadeTo("normal", 0.6); 
},function(){
    $(this).stop().fadeTo("normal", .1); 
});
Tatu Ulmanen
Thank a lot, knew it was something simple!
Wes