Restart jquery.fadeOut () until it disappears

I would like to reload jQuery fadeOut () while it is in the middle of fading.

I have the following statement

$('#status').html('<div style="padding:5px; margin:0 0 0 200px;"><img src="/images/done.png" /> ' + message + '</div>').show().fadeOut(2000); 

When the user performs an action, this statement starts. within 2 seconds, when it works, the user can perform another action that triggers this statement.

Currently, fadeOut must complete before the fadeOut animation plays again.

Is there a way to make fadeOut restart again from the start?

+7
source share
5 answers

Use .stop() before calling .fadeOut() .

Use .stop(true, true) if you wish, if you want it to start with the target values.

+5
source

You can call stop before calling fadeOut. This will start the fadeOut animation. Otherwise, the second fadeOut will be queued after the first.

+1
source
+1
source

Use

 jQuery.stop().fadeOut() 

to prevent the fadeOut animation sequence.

 .stop() can be used to prevent queueing any jQuery Animation 

http://api.jquery.com/stop/

+1
source

This is strange, but in my case the best way was

 //onclick .stop(true, true).fadeIn().stop(true, true); //reset: stop old fadeOut and make visible again .fadeOut(); //again 
0
source

All Articles