I know this is an old stream, but it appeared first when I searched for it, so I assume that others will land here.
Using a callback is what I do if I need a value after the animation finishes, but in my use case I need a height before the animation so that I can expand another element to the same height. To do this, I did the following:
//Get height (start and end) var startHeight = $el.height(); $el.show(); var endHeight = $el.height(); $el.hide(); /**Do something useful with the height here**/ $el2.animate({height: endHeight}); //Slide the element down $el.slideDown();
Because JavaScript is single-threaded, show / hide is never displayed.
source share