Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const target = document.getElementById("dynamic-list"); const observer = new MutationObserver(mutations => { mutations.forEach(m => { if (m.type === "childList") { console.log(`${m.addedNodes.length} nodes added`); } if (m.type === "attributes") { console.log(`Attribute ${m.attributeName} changed`); } }); }); observer.observe(target, { childList: true, attributes: true, subtree: true });
Result
Open