| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/docs/Web/API/MutationObserver | [Back] [Original] |
Get to know MDN better
MutationObserver() MutationObserver DOM
disconnect() MutationObserver observe()
observe() MutationObserver DOM
takeRecords() MutationObserver MutationRecord Array
https://codepen.io/webgeeker/full/YjrZgg/
//
const targetNode = document.getElementById("some-id");
//
const config = { attributes: true, childList: true, subtree: true };
//
const callback = function (mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for (let mutation of mutationsList) {
if (mutation.type === "childList") {
console.log("A child node has been added or removed.");
} else if (mutation.type === "attributes") {
console.log("The " + mutation.attributeName + " attribute was modified.");
}
}
};
//
const observer = new MutationObserver(callback);
//
observer.observe(targetNode, config);
//
observer.disconnect();
| DOM # interface-mutationobserver |
| Web Proxy Viewer | New URL | Original Page |