If I have a DOM element which is dynamically added to the page, and then removed using jQuery's $("#id").remove()
, is it possible to setup a callback, so when the element is removed, I can execute a custom action.
I was thinking of monkey-patching jQuery's remove()
method, so I can check the element's ID and if it matches the one I want, execute the callback, but I'm not sure how.
Are there any better ways to do it? And how can I do it using monkey-patching?
(I'm writing a greasemonkey script, and I can't change the underlying implementation)