Mutation Observer not firing on click

Viewed 26

I want to listen to MutationObserver on click of an element when changes happen in text. But the event is not firing at all. Why is that?

  document.addEventListener("click", function (e) {
    element = e.target;

    let config = {
      attributes: true,
      characterData: true,
    };

    let observer = new MutationObserver((mutationList) => {
      for (let mutation of mutationList) {
        console.log(mutation.type);
      }
    });

    observer.observe(element, config);
  });
<h1 contenteditable="true">Edit me</h1>

0 Answers
Related