JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<h3>Toggle</h3>
<div class="root toggle">
<div class="children"></div>
</div>
</div>
<div class="container">
<h3>Hover</h3>
<div class="root hover">
<div class="children"></div>
</div>
</div>
CSS
div {
margin: 0;
padding: 0;
}
.container {
display: inline-block;
}
h3 {
margin: 0;
text-align: center;
}
.root {
width: 100px;
height: 100px;
padding: 20px;
background-color: darkblue;
}
.children {
display: none;
width: 100px;
height: 100px;
background-color: #CCCCCC;
}
.hover:hover .children {
display: block;
}
JavaScript
$('.toggle').toggle(
function(){ $('.children', this).show(); },
function(){ $('.children', this).hide(); }
);