1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Test avec MutationObserver</title>
</head>
<body>
<p>Une licorne, deux poneys et trois arcs-en-ciel.</p>
<script> "use strict";
new MutationObserver(function (mutationsArray, thisObserver) {
for (let mutation of mutationsArray) {
for (let addedNode of mutation.addedNodes) {
console.log("ajouté:", addedNode);
}
for (let removedNode of mutation.removedNodes) {
console.log("retiré:", removedNode);
}
if (mutation.attributeName) {
console.log("attributeName:", mutation.attributeName);
}
if (mutation.oldValue) {
console.log("oldValue:", mutation.oldValue);
}
}
}).observe(document.documentElement, {
childList : true,
attributes : true,
characterData : true,
subtree : true,
attributeOldValue : true,
characterDataOldValue : true,
});
</script>
</body>
</html> |
Partager