'use strict'; let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; let observerMutationSupport = !!MutationObserver; if(observerMutationSupport){ let observer = new MutationObserver((mutations) => { mutations.forEach((item) => { console.log(item); }); }); const options = { "childList" : true,//子節點的變更 "attributes" : true,//屬性的變更 "characterData" : true,//節點內容或節點文本的變更 "subtree" : true,//全部後代節點的變更 "attributeOldValue" : true,//表示觀察attributes變更時,是否須要記錄變更前的屬性 "characterDataOldValue" : true//表示觀察characterData變更時,是否須要記錄變更前的值 }; observer.observe(document,options); }