[ACCEPTED]-jQuery slideUp().remove() doesn't seem to show the slideUp animation before remove occurs-animation
Might be able to fix it by putting the call 2 to remove in a callback arg to slideUp?
e.g 1
selectedLi.slideUp("normal", function() { $(this).remove(); } );
You need to be more explicit: rather than 2 saying "this" (which I agree should work), you 1 should do this:
$("#yourdiv").slideUp(1000, function() {
$(this).remove();
});
The simplest way is calling the "remove()" function 8 inside slideUp as a parameter like others 7 have said, as this example:
$("#yourdiv").slideUp("normal", function() {
$(this).remove();
});
It is a must 6 to call it inside the anonymous function() to 5 prevent remove() to be executed before the 4 slideUp has ended. Another equal way is 3 to use the jQuery function "promise()". Better 2 for those who like self-explanatory code, like 1 me ;)
$("#yourdiv").slideUp("normal").promise().done(function() {
$(this).remove();
});
Using promises you can also wait for multiple 1 animations to get finished, e.g.:
selectedLi.slideUp({duration: 5000, queue: false})
.fadeOut({duration: 3000, queue: false})
.promise().done(function() {
selectedLi.remove()
})
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.