最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How to wait a fadeout effect and then remove the element? - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question edited Jan 29, 2016 at 8:50 dialogik 9,55218 gold badges78 silver badges121 bronze badges asked Jun 24, 2010 at 22:41 Rodrigo SouzaRodrigo Souza 7,33212 gold badges43 silver badges73 bronze badges 1
  • 1 If you can live with having the element in the dom, but hidden from view: $(this).closest('tr').hide('slow') – Martin Wickman Commented May 23, 2016 at 7:56
Add a comment  | 

1 Answer 1

Reset to default 22

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.

发布评论

评论列表(0)

  1. 暂无评论