JSFiddle - React, Tailwind, and code Playground
HTML
<!-- jQuery.proxy() Example -->
<!-- blog.kevinchisholm.com -->
<div id="container">
<div class="item left">
click me to make the other one red.
</div>
<div class="item right">
click me to make the other one blue.
</div>
</div>
CSS
#container{
width:80%;
margin:20px auto;
text-align:center;
}
.item:hover{cursor:pointer;}
.item{
display:inline-block;
width:40%;
border:4px solid #ccc;
}
.red{background-color:red;}
.blue{background-color:blue;}
JavaScript
var toggleColor = function(className){
if(className){
$(this).toggleClass(className);
};
};
$(".left").on("click",$.proxy(toggleColor,$('.right'),"red"));
$(".right").on("click",$.proxy(toggleColor,$('.left'),"blue"));