JSFiddle - React, Tailwind, and code Playground

by richbuff

HTML

<body onload="handleload();">
  <button id="stylechange1" onclick="changecolor()">Change Color</button>
  <button id="stylechange2" onclick="changevisibility()">Change Visibilty</button>
</body>

JavaScript

function handleload() {
  alert("loaded");
  
  var target = document.body;

  var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      console.log(mutation.type);
    });
  });

  var config = {
    attributes: true,
    childList: true,
    characterData: true
  };

  // pass in the target node, as well as the observer options
  observer.observe(target, config);

  alert("loaded");

  function changecolor() {
    alert("on color");
  }

  function changevisibility() {
    alert("on changevisibility");
  }
}