Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
112
rated 0 times [  115] [ 3]  / answers: 1 / hits: 15301  / 12 Years ago, mon, december 31, 2012, 12:00:00

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();
});

More From » jquery

 Answers
65

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().


[#81148] Saturday, December 29, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
loganl

Total Points: 424
Total Questions: 86
Total Answers: 112

Location: Zimbabwe
Member since Thu, Jul 21, 2022
2 Years ago
;