为什么我不能用jQuery延迟删除调用 [英] Why can't I delay a remove call with jQuery

查看:108
本文介绍了为什么我不能用jQuery延迟删除调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望div淡出然后被删除:

I would like for a div to fadeOut and then be removed:

 $('#div').delay(1000).fadeOut(300);
 $('#div').delay(1300).remove();

不幸的是,这只是直接删除了div,没有任何延迟.为什么我不能延迟删除操作?有什么解决方案?

Unfortunately, this just directly removes the div, with no delays. Why is it that I can't get the remove action to be delayed? What solutions are there?

谢谢

推荐答案

如果要在元素淡出后删除该元素,可以使用fadeOut的回调参数.

If you want the element to be removed after it's done being faded out, you can fadeOut's callback parameter.

$('#div').delay(1000).fadeOut(300, function(){
   $(this).remove();
});

这篇关于为什么我不能用jQuery延迟删除调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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