Mutation Observer on class change

const element = document.getElementById('test'); const observer = new MutationObserver(function (event) { console.log(event); }); observer.observe(element, { attributes: true, attributeFilter: ['class'], childList: false, characterData: false }); // you will notice the firing when the class of the said element is changing.

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.