Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if element is in the fadeIn or fadeOut state ('action')

Tags:

jquery

I need to stop(cancel) current .fadeIn(5000) and start the same fadeIn from the beginning, once a button is clicked (otherwise next fadeIn will start only after 5000). How can I check, if div is actively fading and how to can cancel it (I assume I could just .hide())?

like image 861
Stewie Griffin Avatar asked Feb 24 '11 00:02

Stewie Griffin


1 Answers

Use .stop(). You don't need to test if fadeIn is running, if it is not, stop has not effect.

You still have to hide it though. So it would be something like:

$('selector').stop(true).hide().fadeIn(5000);
like image 134
Felix Kling Avatar answered Sep 17 '22 22:09

Felix Kling