I try $('somediv').fadeOut.remove();
but it only remove it, bang... it dont wait for the nice fadeOut, and THEN remove
why.. how to respect fadeout, and then remove..
jQuery fadeIn() Method The fadeIn() method gradually changes the opacity, for selected elements, from hidden to visible (fading effect). Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: This method is often used together with the fadeOut() method.
JQuery offers four fading methods that allow you to change the transparency of elements. These methods include, fadeIn(), fadeOut(), fadeToggle(), and fadeTo().
The jQuery fadeOut() method is used to fade out a visible element. Syntax: $(selector). fadeOut(speed,callback);
The . fadeOut() method animates the opacity of the matched elements. Once the opacity reaches 0, the display style property is set to none , so the element no longer affects the layout of the page. Durations are given in milliseconds; higher values indicate slower animations, not faster ones.
Use a callback:
$('somediv').fadeOut( function() { $(this).remove(); });
The code in the callback function you're passing to fadeOut()
(docs) will not execute until the animation is complete.
Example: http://jsfiddle.net/p2LWE/
An alternative would be to queue()
(docs) the remove()
(docs) , but I think the callback is better.
$('somediv').fadeOut()
.queue(function(nxt) {
$(this).remove();
nxt();
});
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