JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>Item 1</li>
<li>Item 2
<ul>
<li>Sub Item</li>
</ul>
</li>
<li>Item 3</li>
</ul>
CSS
.hover { background: #ddd; }
li { background: #fff; }
JavaScript
$('li').mouseover(function(e){
$(this).addClass("hover").parents().removeClass("hover");
e.stopPropagation();
}).mouseout(function(){
$(this).removeClass("hover");
});