I have some JQuery code in the click event handler for a checkbox that updates the value of a span control on the page, then animates the background color of the span tag to yellow and then fade back to white in about a second to draw attention to the user that the value of the span has changed. The problem is that if a user clicks repeatedly on the checkbox, then the animation occurs over and over for how ever many times the user clicked. Any one know how to prevent the JQuery animation from occuring if an animation is already in progress.
Awesome, that works perfectly! Thanks!
Russ Clark
2009-04-15 16:12:54
+2
A:
Simply call stop() on the object before animating it:
$('#button').click( function() {
$('#animatedSpan').stop().animate( { } );
});
Pim Jager
2009-04-15 15:51:44