Reputation: 47995
Here there is an example :
<div id='example'>
ciao
</div>
$('#example').fadeOut(600).delay(600).remove();
I want to fadeout the element, than remove it, but looks like that .remove()
ignore .delay()
(so the element is removed immediatly).
How can I fix this trouble?
Upvotes: 2
Views: 204
Reputation: 59002
Instead of using delay, pass a callback to fadeOut:
$('#example').fadeOut(600, function() {
$("#example").remove();
});
Upvotes: 3
Reputation: 222358
Specify a callback instead
$('#example').fadeOut(600, function() { $(this).remove(); });
Upvotes: 4
Reputation: 154918
.remove
is not about animating, so .delay
has no effect.
What you can do is passing a function which gets executed when the animation has finished (the callback argument - see http://api.jquery.com/fadeOut/):
$('#example').fadeOut(600, function() {
$(this).remove();
});
http://jsfiddle.net/pimvdb/Sny7P/1/
Upvotes: 6