I have a div that I want to remove using remove(). I want to show an animation before/while removal of div. I have only been able to show the animation when hiding the div.
If i want to show the animation then do remove(). How is this done???
Code so far:
//Delete Button - delete from cart
$('.ui-icon-trash').live('click',function() {
$(this).closest('li').hide("puff", {}, 1000)
});
hide() sets the matched elements' CSS display property to none . remove() removes the matched elements from the DOM completely. detach() is like remove() , but keeps the stored data and events associated with the matched elements.
jQuery hide() Method The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: To show hidden elements, look at the show() method.
The toggle() method toggles between hide() and show() for the selected elements. This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible - This creates a toggle effect.
Do it in the callback function for .hide()
(jQuery UI .hide()
reference), like this:
$('.ui-icon-trash').on('click', function() {
$(this).closest('li').hide("puff", {}, 1000, function() {
$(this).remove();
});
});
The function at the end runs as a callback, executing when the animation is done...so when you want :)
You might check this also:
$(this).hide("puff").delay(10).queue(function(){$(this).remove();});
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