remove()函数中的jQuery回调 [英] jQuery callback within the remove() function

查看:93
本文介绍了remove()函数中的jQuery回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在从页面中删除DIV后调用函数。

I need to call a function after a DIV has been removed from the page.

我试过像这样添加一个回调,但没有运气。有什么建议吗?

I have tried adding a callback like so, but no luck. Any suggestions?

$(foo).remove( function() {
   stepb();
});


推荐答案

试试这个

$。when($('#foo')。remove())。then(stepb());
[ Example1 ] [1]和[ Example2 ] [2]。

$.when($('#foo').remove()).then(stepb()); [Example1][1] and [Example2][2].

$('#foo').remove();
stepb();

由于删除方法<$在$ code> remove()已经完成了。所以,不需要使用 $。when()。then()

​Since the remove method in jQuery is synchronous, stepb() will be invoked after remove() has finished. So, no need to use $.when().then().

这篇关于remove()函数中的jQuery回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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