I am sure I read about this the other day but I can't seem to find it anywhere.
I have a fadeOut()
event after which I remove the element, but jQuery is removing the element before it has the chance to finish fading out.
How do I get jQuery to wait until the element had faded out, then remove it?
jQuery delay() Method The delay() method sets a timer to delay the execution of the next item in the queue.
To call a jQuery function after a certain delay, use the siteTimeout() method. Here, jQuery fadeOut() function is called after some seconds.
The jQuery stop() method is used to stop an animation or effect before it is finished. The stop() method works for all jQuery effect functions, including sliding, fading and custom animations.
$ sign is just a valid javascript identifier which is used as an alias for jQuery. Prototype, jQuery, and most javascript libraries use the $ as the primary base object (or function). Most of them also have a way to relinquish the $ so that it can be used with another library that uses it.
With jQuery 1.6 version you can use the .promise()
method.
$(selector).fadeOut('slow'); $(selector).promise().done(function(){ // will be called when all the animations on the queue finish });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With