如何等待淡出效果然后删除元素?

Rod*_*uza 8 javascript jquery

我有一个<tr>将在删除按钮时被删除,但在做之前.remove()empty()我想等待一些fadeOut()效果.

$(this).closest('tr').fadeOut();
setTimeout("$(this).closest('tr').remove()",1000);
Run Code Online (Sandbox Code Playgroud)

它不起作用,它只会淡出.

Sin*_*nan 19

你需要一个回调fadeOut()

$(this).closest('tr').fadeOut(400, function(){
    $(this).remove();
});
Run Code Online (Sandbox Code Playgroud)

它在fadeOut()操作完成后立即触发回调,在这种情况下400ms.

希望这会有所帮助,思南.