I am sure I read about this the other day but I can't seem to find it anywhere.
I have a fadeOut() event after which I remove the element, but jQuery is removing the element before it has the chance to finish fading out.
How do I get jQuery to wait until the element had faded out, then remove it?

推荐答案

可以指定回调函数:

$(selector).fadeOut('slow', function() {
    // will be called when the element finishes fading out
    // if selector matches multiple elements it will be called once for each
});

Documentation here.

Jquery相关问答推荐

JQuery DateTimePicker-在 Select 中抓取星期几

5 秒后关闭 jQuery 弹出模式

ASP.NET MVC - Ajax 将空值传递给控制器

即使我使用 [FromBody] C# 从视图(Ajax)发送请求时在控制器中收到 NULL 对象

为什么 .join() 不能与函数参数一起使用?

如何使用 jQuery 禁用粘贴(Ctrl+V)?

jQuery $(document).ready () 触发两次

在范围内设置文本

jQuery UI 自动完成宽度未正确设置

实用的 javascript 面向对象设计模式示例

按百分比zoom div的内容?

在单击事件上判断 Ctrl / Shift / Alt 键

Jquery:如何判断元素是否具有某些 css 类/样式

CORS POST 请求可以使用纯 JavaScript,但为什么不使用 jQuery?

如何使用 JSON、jQuery 将一组复杂对象发布到 ASP.NET MVC 控制器?

JQuery - 按值查找单选按钮

jquery 检测某些类的 div 已添加到 DOM

更改 url 而不使用 javascript 重定向

带有 LIKE 的 Spring JPA @Query

如何获取 jQuery 下拉值 onchange 事件