JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<span>click me</span>
</div>
CSS
div {
height: 200px;
width: 200px;
background: green;
}
span {
cursor: pointer;
}
JavaScript
$('span').toggle(
function() {
$(this).closest('div').css('background', 'red');
}, function() {
$(this).closest('div').css('background', 'green');
})