JSFiddle - React, Tailwind, and code Playground

by Gunnar

HTML

<div id="bodySimulation">
  I'm the body.
</div>

JavaScript

/* simulation of first javascript file */
function clickHandler(domElement) {
  alert(domElement.innerHTML);
}

/* simulation of second javascript file */
function renderDiv(content) {
  var div = document.createElement("div");
  div.innerHTML = content;
  div.addEventListener("click", function() {
    clickHandler(this);
  });
  document.getElementById("bodySimulation").appendChild(div);
}
renderDiv("a div");
renderDiv("another div");