Answers for "js on element change"

5

js select on change value

document.getElementById('my-select').addEventListener('change', function() {
  console.log('You selected: ', this.value);
});
Posted by: Guest on May-14-2020
1

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);
Posted by: Guest on July-01-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language