Is this possible? My HTML looks like this:
<ul>
<li> <a> link </a> </li>
<li> <a> link </a> </li>
<li> <a> link </a>
<ul>
<li> <a> sub-link </a> </li>
<li> <a> sub-link </a> </li>
<li> <a> sub-link </a> </li>
</ul>
</li>
</ul>
Basically I want to trigger the hover CSS rule on the parent menu link when the mouse is over a child menu link.
If you use
.hover()it’ll affect the parent as well, since that’s how themouseenterandmouseleaveevents work, for example:You can give it a try here, unlike
mouseoverandmouseout, the events don’t fire when entering/leaving children, so the action taken on the parent isn’t “undone” until you actually leave the parent as well, which seems to be what you’re after.Or, use pure CSS if you’re just doing styling, like this (doesn’t work in IE6):
You can test it here.