📌  相关文章
📜  javascript 检测元素数量何时发生变化 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:58.991000             🧑  作者: Mango

代码示例1
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);