JSFiddle - React, Tailwind, and code Playground
by quatzael
HTML
<label>
<div class="item" style="background: #EEE; padding: 20px; width: 40px; height: 40px;">
<input type="checkbox" class="chb">
</div>
</label>
<label>
<div class="item" style="background: #EEE; padding: 20px; width: 40px; height: 40px;">
<input type="checkbox" class="chb">
</div>
</label>
<script type="text/javascript">
$(".item").click(
function(){
if (!$(this).closest(".item").find(".cnb").is(":checked"))
{
$(this).css("background","#EEE");
}
else
{
$('.chb').prop('checked', 'false');
$(this).css("background","red");
window.alert("else");
}
});
</script>