Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait a fadeout effect and then remove the element?

I have a <tr> which will be removed when clicked in delete button, but before doing .remove() or empty() I'd like to wait for some fadeOut() effect.

$(this).closest('tr').fadeOut();
setTimeout("$(this).closest('tr').remove()",1000);

is not working, it only fades out.

like image 223
Rodrigo Souza Avatar asked Jun 24 '10 22:06

Rodrigo Souza


1 Answers

You need a callback after fadeOut()

$(this).closest('tr').fadeOut(400, function(){
    $(this).remove();
});

It fires the callback just after the fadeOut() operation is done, in this case after 400ms.

Hope this helps, Sinan.

like image 59
Sinan Avatar answered Sep 30 '22 18:09

Sinan