JQuery callback in remove () function

I need to call a function after removing the DIV from the page.

I tried adding a callback like this, but no luck. Any suggestions?

$(foo).remove( function() { stepb(); }); 
+7
source share
2 answers

try it

$ when ($ ('# Foo') delete ().), and then (stepb ()); .. Hit> [ Example1 ] [1] and [ Example2 ] [2].

 $('#foo').remove(); stepb(); 

Since the remove method in jQuery is synchronous, stepb() will be called after remove() . Therefore, there is no need to use $.when().then() .

+15
source

By default, no event occurs when something is removed from the DOM.

Look at this question for some good workarounds: jQuery is a trigger event when an element is removed from the DOM

0
source

All Articles