监控节点属性变换

 

 

let node = document.body; // or document.getElementById('nodeid')
                var mutationObserver = new MutationObserver(function(mutations) {
                  mutations.forEach(function(mutation) {
                    console.log(mutation);
                  });
                });
                // Starts listening for changes in the root HTML element of the page.
                //mutationObserver.observe(document.documentElement, {
                mutationObserver.observe(node.parentNode, {
                    attributes: true,
                  characterData: true,
                  childList: true,
                  subtree: true,
                  attributeOldValue: true,
                  characterDataOldValue: true
                });

 

posted @ 2020-12-12 12:39  zyip  阅读(94)  评论(0编辑  收藏  举报