Stop Fadin/fadeout Event Jquery
I have a dive that flashs once on click. If you press the button multiple times it will keep flashing until the click count has been executed. I would like to so then if the user w
Solution 1:
Use stop
to stop previous animations.
$('button').click(function () {
$('div').stop(true, true).fadeOut().fadeIn().fadeOut().fadeIn();
// ^^^^^^^^^^^^^^^^
});
Demo: https://jsfiddle.net/tusharj/va6njdry/1/
Docs: http://api.jquery.com/stop/
Stop the currently-running animation on the matched elements.
Edit
Thanks to @AWolff
You can also use finish
$('button').click(function () {
$('div').finish().fadeOut().fadeIn().fadeOut().fadeIn();
// ^^^^^^^^
});
Demo: https://jsfiddle.net/tusharj/va6njdry/4/
Docs: https://api.jquery.com/finish/
Stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements.
Post a Comment for "Stop Fadin/fadeout Event Jquery"