JSFiddle - React, Tailwind, and code Playground

by Barry Margolin

HTML

<div class="parent">
    <div class="child"></div>
</div>

CSS

.child {
    height: 10px;
    background: #eee;
}
.parent {
    position: relative;
    padding: 45px;
    background: #aaa;
}

JavaScript

$('.parent').click(function() {
    alert(1);
    $(this).find('.child').click();
});

$('.child').click(function(e) {
    e.stopPropagation(); // Prevent bubbling to parent, to avoid loop
    alert(2);
});