试图使一些divs淡出然后被删除 [英] trying to make some divs fadeOut and then be removed

查看:83
本文介绍了试图使一些divs淡出然后被删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使某些divs淡出,然后将其删除.

I'm trying to make some divs fadeOut and then be removed.

$("article.articles .thumb a").click(function() {
    $(this).parent().parent().addClass("selected");
    $("article.post").not(".selected").fadeOut(500).delay(1500).remove();
    $('#stream').isotope('reLayout');
});

但是div会立即移除而不会褪色.

But the divs are removed right away without fading.

我在做什么错了?

推荐答案

您可以使用fadeOut()回调函数,该函数在淡入淡出效果完成后执行.

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

.fadeOut([持续时间] [,回调])

.fadeOut( [duration] [, callback] )

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

或:

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

这篇关于试图使一些divs淡出然后被删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆