Mutation Observer simple example

const element = document.querySelector('.element'); const config = { attributes: true, childList: true, subtree: true }; const callback = function(mutationsList, observer) { for(let mutation of mutationsList) { if (mutation.type === 'childList') { console.log('Look I changed! ????'); } } }; var observer = new MutationObserver(callback); observer.observe(element, config);

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.