Created
April 4, 2020 08:43
-
-
Save condor-bird/d24fa9e33ed6804a13d670be63bb01e7 to your computer and use it in GitHub Desktop.
Is there a JavaScript DOM change listener?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MutationObserver = window.MutationObserver || window.WebKitMutationObserver; | |
var observer = new MutationObserver(function(mutations, observer) { | |
// fired when a mutation occurs | |
console.log(mutations, observer); | |
// ... | |
}); | |
// define what element should be observed by the observer | |
// and what types of mutations trigger the callback | |
observer.observe(document, { | |
subtree: true, | |
attributes: true | |
//... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment