监控节点属性变换

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
                });
原文地址:https://www.cnblogs.com/zyip/p/14124294.html