JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
<div id="nested">
<span id="someElement">Some Text</span>
</div>
</div>
CSS
#container {
width: 500px;
height: 500px;
background-color: yellow;
border: 1px solid black;
}
#nested {
width: 100px;
height: 100px;
background-color: red;
}
#someElement {
background-color: green;
}
JavaScript
$("#container").on('click', function(event) {
if(this === event.target) {
alert("container was clicked");
}
});