I need to call a function after a DIV has been removed from the page.
I have tried adding a callback like so, but no luck. Any suggestions?
$(foo).remove( function() {
stepb();
});
I need to call a function after a DIV has been removed from the page.
I have tried adding a callback like so, but no luck. Any suggestions?
$(foo).remove( function() {
stepb();
});
Try this
$.when($('#foo').remove()).then(stepb());
[Example1][1] and [Example2][2].
$('#foo').remove();
stepb();
Since the remove
method in jQuery
is synchronous, stepb()
will be invoked after remove()
has finished. So, no need to use $.when().then()
.
By default there is no event fired when something is removed from the DOM.
Take a look at this question for some good workarounds: jQuery - Trigger event when an element is removed from the DOM