trying to make some divs fadeOut and then be removed

萝らか妹 提交于 2019-12-02 00:15:24

you can use fadeOut() callback function which is executed after fade effect is complete.

.fadeOut( [duration] [, callback] )

$("article.post").not(".selected").fadeOut(500, function(){
   $(this).remove();
})

or:

$("article.post").not(".selected").fadeOut(500).delay(2000).queue(function(){
   $(this).remove()
})

You are not waiting for the div to fade out before removing it. You need to create a callback function and call remove inside it.

Use this Snippet-

   $("article.post").not(".selected").fadeOut(500, function(){
                            $("article.post").not(".selected").remove();
                        });
$("article.articles .thumb a").click(function() {
    $(this).parent().parent().addClass("selected");
    $("article.post").not(".selected").fadeOut(500, function(){
    setTimeout(function(item){ 
      jQuery(item).remove(); }, 1500, $(this));
});
    $('#stream').isotope('reLayout');
});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!