How to fire an event when an ancestor of an element is removed or no longer开发者_如何转开发 displayed in the document?
Thanks
If the ancestor of an element is removed, then the DOM subtree is also removed.
- In this case you don't have elements to fire because they are gone
If the ancestor is invisible then DOM subtree is also invisible.
- In this case ele you have to go there by the id
$("#undisplayed_element_id")
I think there is no command like this though:
$("#the_id").hey_im_going_to_vanish(function()...)
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
}
精彩评论