JSFiddle - React, Tailwind, and code Playground

by Graham Walters

HTML

<div id="a" onclick="clickEvent(event, this);">a
  <div id="b" onclick="clickEvent(event, this);">b</div>
</div>

CSS

#a {
  width: 150px;
  height: 150px;
  background-color: blue;
  color: white;
}

#b {
  width: 50px;
  height: 50px;
  background-color: red;
   color: white;
}

JavaScript

function clickEvent(e, o) {
  alert(o.id);
  event = e || window.event;
  event.stopPropagation();
}