jQuery - 從 DOM 中刪除元素時觸發事件 - jQuery - Trigger event when an element is removed from the DOM

問題:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章