Sunday, April 8, 2012

DOM Mutation event in JQuery or vanilla Javascript



Are there any DOM mutation events in JQuery or in vanilla Javascript that fire cross browser?





To clarify, say I have a script on my page which inserts a div into the body. I don't have access to the script and I don't know when the div has been inserted. I was wondering if there's a DOM mutation event that I can add a listener for to know when the div has been inserted. I know I can use some kind of timer to periodically check for the div but I don't really like the overhead that this would impose.



Source: Tips4all

1 comment:

  1. There are some deprecated DOM mutation events, such as DOMNodeInserted and DOMNodeInsertedIntoDocument that still work for me in Chrome 14 and IE9.

    See an example at http://jsfiddle.net/Kai/WTJq6/

    See them all on the W3C draft at http://www.w3.org/TR/DOM-Level-3-Events/

    ReplyDelete