22 lines
518 B
JavaScript
22 lines
518 B
JavaScript
const targetNode = document.querySelector('ol');
|
|
|
|
const config = {
|
|
attributes: true,
|
|
childList: true,
|
|
characterData: true
|
|
};
|
|
|
|
const callback = mutations => {
|
|
mutations.forEach(mutation => {
|
|
if (mutation.type === 'childList') {
|
|
const listValues = Array.from(targetNode.children)
|
|
.map(node => node.innerHTML)
|
|
.filter(html => html !== '<br>');
|
|
console.log(listValues);
|
|
}
|
|
});
|
|
}
|
|
|
|
const observer = new MutationObserver(callback);
|
|
|
|
observer.observe(targetNode, config); |