If an item is being deleted then I would like to fade it out and slide the other elements up to fill the empty space. Now, when I use fadeOut()
the item doesn't have a height at the end which results in the other items jumping up (instead of sliding up nicely).
How can I slideUp()
and element right after fadeOut()
?
Sounds like it would be better to use the jQuery fadeTo command
$(function() {
$("#myButton").click(function() {
$("#myDiv").fadeTo("slow", 0.00, function(){ //fade
$(this).slideUp("slow", function() { //slide up
$(this).remove(); //then remove from the DOM
});
});
});
});
By performing each command in the callback function of the preceding command, the command will not run until the previous one completes; a "jump" occurs when the element is removed from the DOM without waiting for the slideUp to complete.