I am trying to run a function once an element has been deleted from the html.
I added $("selector").on('DOMNodeRemoved',function(){
//do stuff
});
The issue is that while the function in running the element that has been deleted is still there, and is only removed after the function finishes running. Is there a way to run this function after this listener has completed?
答案 0 :(得分:0)
could add a short setTimeout
so code gets run at end of the event loop
$("selector").on('DOMNodeRemoved',function(){
setTimeout(function(){
//do stuff
},10);
});