jQuery - delay and fadeout before remove

jquery

Solution

why not

jQuery(this).closest('.' + parent).fadeOut(1000, function(){
    $(this).remove()
});

You should make use of the complete callback provided by .fadeOut() in this case

jQuery("#container").on("click", ".remove", function (e) {
    e.preventDefault();
    var $this = jQuery(this), parent = $this.data('parent');
    $this.closest('.' + parent).fadeOut(1000).delay(1000).remove();
})

Problem

I am trying to do a `.delay()` and `.fadeOut()` then `.remove()` But `delay` and `fadeout` has no effect in `remove` Here is my code: ``` jQuery("#container").delegate(".remove", "click", function (e) { e.preventDefault(); var parent = jQuery(this).data('parent'); jQuery(this).closest('.' + parent).fadeOut(1000).delay(1000).remove(); }) ```

Original source

Related problems