Horje
mutation observer js Code Example
mutation observer js
const observer = new MutationObserver(list => {
    console.log('mutation list', list);
});
observer.observe(document.body, {
    attributes: true,
    childList: true,
    subtree: true
});
// perform any DOM change action in your page. e.g. show/hide/remove
How to write a mutation observer js
let mList = document.getElementById('myList'),
            options = {
                childList: true,
                attributes: true,
                subtree: true
            },
            observer = new MutationObserver(mCallback);

        function mCallback(mutations) {
            for (let mutation of mutations) {
                // If you remove a child from the container you are watching
                if (mutation.type === 'childList') {
                    console.log('Mutation Detected: A child node has been added or removed.');
                }
                // If you use setAttribute to add a class or ID to an element
                if (mutation.type === 'attributes') {
                    console.log('Mutation Detected: An attribute has been added or removed.');
                }

                if (mutation.type === 'subtree') {
                    console.log('Mutation Detected: A subtree has been added or removed.');
                }
            }
        }

observer.observe(mList, options);




Javascript

Related
ant design table sort string perfectly Code Example ant design table sort string perfectly Code Example
chart js y axis integer Code Example chart js y axis integer Code Example
jquery merge objects Code Example jquery merge objects Code Example
click button javascript Code Example click button javascript Code Example
JavaScript find the shortest word in a string Code Example JavaScript find the shortest word in a string Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9