Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript detect when number of elements change

const targetNode = document.body;
const config = { childList: true, subtree: true };

const callback = function(mutationsList, observer) {
    for(let mutation of mutationsList) {
        if (mutation.type === 'childList') {
            // Elements have changed
        }
    }
};

const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
 
PREVIOUS NEXT
Tagged: #javascript #detect #number #elements #change
ADD COMMENT
Topic
Name
4+3 =