Skip to content

Instantly share code, notes, and snippets.

@rdricco
Last active January 7, 2020 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdricco/cfdedbd3d5caeffcdd802bcc9574cad1 to your computer and use it in GitHub Desktop.
Save rdricco/cfdedbd3d5caeffcdd802bcc9574cad1 to your computer and use it in GitHub Desktop.
js observer
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