How do you cancel a jQuery fadeOut() once it has started?
Also, you can test if an element is in the middle of an animation using the :animated
selector:
$('#message').mouseover(
function () {
if($(this).is(':animated')) {
$(this).stop().animate({opacity:'100'});
}
}
);
In my case stop()
merely didn't work at least in Firefox, after searching I figured out that It should be stop(true, true)
:
$('#message').mouseover(
function () {
$(this).stop(true, true).fadeOut();
}
);
stop(): Stops the currently-running animation on the matched elements.
or even you can use finish()
instead:
$('#message').mouseover(
function () {
$(this).finish().fadeOut();
}
);
but there is a side effect about finish(), it stops all other running animations too.
finish(): Stops the currently-running animation, remove all queued animations, and complete all animations for the matched elements.
Read more here.
Check out the stop function
http://docs.jquery.com/Effects/stop#clearQueuegotoEnd