I want to change the color of <li>
element on hover. problem is that when I hover on child li elements, the color of parent <li>
element also getting change.
See following example:
HTML:
<div id="tree">
<ul>
<li>apple</li>
<li>banana</li>
<li>mango
<ul>
<li>date</li>
<li>pear</li>
<li>fig</li>
</ul>
</li>
</ul>
CSS:
#tree > ul > li:hover {
background:brown;
}
#tree > ul > li:hover > ul >li{
background:white;
}
#tree > ul > li > ul > li:hover {
background:yellow;
}
https://jsfiddle.net/1v57nwg8/
Any help using css, javascript or jquery appreciated.