JSFiddle - React, Tailwind, and code Playground
HTML
<div class="x">I am X</div>
<div class="y">I am Y</div>
<div class="x y">I am Both</div>
CSS
div {
display: inline-block;
padding: 5px 8px;
background-color: #ddd;
}
JavaScript
$('.x').each(function() {
this.onclick = function() {
alert('X');
};
});$('.y').each(function() {
this.onclick = function() {
alert('Y');
};
});