Last active
January 7, 2020 17:42
-
-
Save rdricco/cfdedbd3d5caeffcdd802bcc9574cad1 to your computer and use it in GitHub Desktop.
js 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
function observeElement(el) { | |
// select the target node | |
var target = document.querySelector(el); | |
// create an observer instance | |
var observer = new MutationObserver(function(mutations) { | |
console.log('mutação detectada'); | |
}); | |
// configuration of the observer: | |
var configObserver = { attributes: true, childList: true, characterData: true }; | |
// pass in the target node, as well as the observer options | |
observer.observe(target, configObserver); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment