How can I stop the clicking function? Until it ends with animation?

I need to know how I can stop the click function when the animation ends

here is my code

$(function () { $('legend').click(function () { $(this).parent().find('.content').slideToggle("slow"); }); }); 
+8
jquery
source share
2 answers

Change your selector to exclude :animated elements using :not :

  $(function () { $('legend').click(function () { $(this).parent().find('.content:not(:animated)').slideToggle('slow'); }); }); 

Working example : http://jsfiddle.net/andrewwhitaker/acKtG/

+6
source share

Here you go. Just check the bool checkbox. During the animation, return from the click event, otherwise set the flag and animation, then reset the flag at the end of the animation callback:

  $(function () { $('legend').click(function () { if($(this).data('animating') !== true) { $(this).data('animating',true); $(this).parent().find('.content').slideToggle("slow", function(){$(this).data('animating',false);}); } else { return false; } }); }); 
0
source share

All Articles