Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body onclick="myFunction(event)">
<h1>The Element Object</h1>
<h2>The tagName Property</h2>
<p>Click on any elements in this document to see which element triggered the onclick event.</p>
<button>This is a button</button>
<p><span>This is span element.</span></p>
<p id="demo"></p>
<script>
function myFunction(event) { 
  const element = event.target;
  document.getElementById("demo").innerHTML = "Triggered by " + element.tagName;
}
</script>
</body>
</html>