问题:
I'm trying to figure out how to execute some js code when an element is removed from the page:我试图弄清楚如何在从页面中删除元素时执行一些 js 代码:
jQuery('#some-element').remove(); // remove some element from the page
/* need to figure out how to independently detect the above happened */
is there an event tailored for that, something like:是否有为此量身定制的活动,例如:
jQuery('#some-element').onremoval( function() {
// do post-mortem stuff here
});
解决方案:
参考一: https://stackoom.com/question/9ERq参考二: jQuery - Trigger event when an element is removed from the DOM