jQuery remove() 回调? [英] jQuery remove() callback?
本文介绍了jQuery remove() 回调?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有官方的方法可以连接到 jQuery.remove() 以便可以在之前/之后调用函数?
Is there an official way to hook in to jQuery.remove() so that a function can be called before/after?
我有一个系统,其中某些处理程序附加到元素,有时这些元素会被删除(例如,一个 UI 小部件,其主要元素被页面上的某些其他操作删除).如果可以通知处理程序他们的主要元素已被删除,我可以更轻松地运行清理例程.
I have a system whereby certain handlers are attached to elements, and sometimes these elements are removed (eg. a UI widget whose primary element is removed by some other action on the page). If handlers could be notified that their primary element was removed, I can run cleanup routines a little easier.
推荐答案
你可以使用 jQuery.when():
$.when($('div').remove()).then( console.log('div removed') );
这篇关于jQuery remove() 回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文