how to make jQuery code wait until an animation is finished
Want to execute some code, but only after an animation has finished? Try using a callback.
This could be useful, for example, for fading an item by animating its opacity then removing it from the page, or for running a conditional statement based on an element's properties after it is done animating instead of when the animation is called; the list goes on.
The pseudocode looks like this:
$(selector).animate({something}, function(){  if($(selector).property=value){   then do something  }; });
The section in bold is the callback, and is is only executed when the animation is finished.
Enjoy!










