I need assistance with modifying the menu structure generated by Wordpress. Specifically, I want to change the background of #header-nav li ul.children li a
when
#header-nav li ul.children li ul.children li a:hover
is active.
Could someone provide guidance on the syntax required for this task?
<div id="header-nav">
<li class="page_item page-item-10"><a>Marketing</a>
<ul class='children'>
<li class="page_item page-item-153"><a href="{link}">The Marketing Team</a></li>
<li class="page_item page-item-148"><a href="{link}">Ideas</a></li>
<li class="page_item page-item-136"><a href="{link}">Referrals</a></li>
<li class="page_item page-item-156"><a href="{link}">Partnerships</a></li>
</ul>
</li>
</div>
My current approach involves identifying the parent class of the hovered element (e.g. 'page_item page-item-10' when the user hovers over 'Ideas') and using the .hover() function to change the background accordingly. However, I am unsure of how to retrieve the parent class. Any suggestions?
/**
* Highlighs parent elements in a menu when a child is being hovered over
*/
$(function(){
$('#header-nav li ul.children li ul.children li a').hover(function(e){
/** Get the parent of the element that is being hovered over */
var parent = ???;
/** Set the background of the parent element on 'mouseenter' */
$('#header-nav li ul.children li.'+parent+' a').css('background-color', '#0066B5');
}, function(){
/** Reset the background of all matching elelments of 'mouseleave' */
$('#header-nav li ul.children li a').css('background-color', '#000');
})
});