JSFiddle - React, Tailwind, and code Playground

by Tom O

HTML

<div id="myCoolDiv">
  <p class="myCoolClass">This text will get replaced with the name of the div!</p>
</div>

JavaScript

function showElementId(element) {
  element.innerHTML = element.id;
}

showElementId(document.getElementById("myCoolDiv"));