aboutsummaryrefslogtreecommitdiffhomepage
path: root/snippets/javascript_mutationoberserver
blob: 9962aacfdbd1f22482debaee37162b3fc2c6a0e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
new window.MutationObserver((mutations) => {
  for (const mutation of mutations) {
    console.log(mutation)
    console.log('mutation', mutation.target.innerHTML)
    console.log('mutation', mutation.target.classList)
  }
}).observe(item, {
  attributes: true,
  attributeFilter: ['class'],
  attributeOldValue: true,
  characterDataOldValue: true,
  childList: true,
  subtree: true,
})