开发者

jQuery Ancestor Listener

开发者 https://www.devze.com 2022-12-27 14:52 出处:网络
How to fire an event when an ancestor of an element is removed or no longer开发者_如何转开发 displayed in the document?

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号