Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animate and remove a div - jquery

I'm removing a div from body with a fadeout effect with a delay.

$('#mydata div').each(function(i) {                 

        $(this).delay(200*i).fadeOut(1000);
            $(this).animate({
                "opacity" : "0",
            });

    });
    $('#mydata').remove();

But if i use $('#mydata').remove() animation doesn't work any solutions .. ?

like image 645
user1184100 Avatar asked Dec 01 '22 23:12

user1184100


1 Answers

Something like this :

$('#mydata div').each(function(i) {                 

        $(this).delay(200*i).fadeOut(1000);
            $(this).animate({
                "opacity" : "0",
                },{
                "complete" : function() {
                      $('#mydata').remove();
                }
            });

    });
like image 108
yoda Avatar answered Dec 23 '22 09:12

yoda