問題:
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