JSFiddle - React, Tailwind, and code Playground

by yangchenyun

JavaScript

const newElem = (id) => {
  const n = document.createElement('div');
  n.id = id;
  return n;
}

const observer = new MutationObserver((mutations) => {
  for (m of mutations) {
    for (node of m.addedNodes) {
      {
        if (node.id === 'zhaoz') {
          console.info('welcome onboard!');
        }
      }
    }
  }
});

document.body.appendChild(newElem('web-arch'));
observer.observe(
  document.getElementById('web-arch'), {
    childList: true
  });

document.getElementById('web-arch')
  .appendChild(newElem('zhaoz'))