Created
July 14, 2017 07:51
-
-
Save fjaguero/bf1c490fb64e4703782908093e9505b1 to your computer and use it in GitHub Desktop.
Simple observer
This file contains 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
// select the target node | |
var target = document.querySelector('#some-id'); | |
// create an observer instance | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
console.log(mutation.type); | |
}); | |
}); | |
// configuration of the observer: | |
var config = { attributes: true, childList: true, characterData: true }; | |
// pass in the target node, as well as the observer options | |
observer.observe(target, config); | |
// later, you can stop observing | |
observer.disconnect(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment