MutationObserver接口
作者:互联网
MuataionObserver 替代了 MutationEvent
当被监听的节点发生变化时,执行某段函数
btn.onclick = function() {
document.body.removeChild(document.getElementById('test'))
}
let observer = new MutationObserver(() => {
console.log(4);
});
observer.observe(document.body, {
attributes: false, //节点属性如class等改变是否触发
childList: true //子节点改变
characterData: false //
});
标签:body,false,observer,接口,MutationObserver,document,节点 来源: https://www.cnblogs.com/Lilc20201212/p/15742532.html