Skip to content Skip to sidebar Skip to footer

How Do You Do Something If The DOM Is Changed?

How can I detect when the document changes? I know I could do something like this: var lastHTML = document.body.innerHTML; setInterval(function() { if(document.body.innerHTML != la

Solution 1:

There's the old DOM Mutation Events, and there's the new DOM Mutation Observers.


For a quick overview of them both (and why the newer [more complex] API is better), check out this post:

Detect DOM Changes with Mutation Observers.


P.S. Don't miss the comments there...


Post a Comment for "How Do You Do Something If The DOM Is Changed?"