How to fire an event when an ancestor of an element is removed or no longer displayed in the document?
Thanks
How to fire an event when an ancestor of an element is removed or no longer displayed in the document?
Thanks
There is no event to be triggered when an element is removed. However, you can make a check if element is not present, perform some action, for example:
if (! $('#element_id_here').get(0))
{
// your code here
}
If the ancestor of an element is removed, then the DOM subtree is also removed.
If the ancestor is invisible then DOM subtree is also invisible.
$("#undisplayed_element_id")I think there is no command like this though:
$("#the_id").hey_im_going_to_vanish(function()...)