Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7197201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:55:50+00:00 2026-05-28T20:55:50+00:00

I have the following menu structure (created by WordPress, so can’t change the IDs/Classes)

  • 0

I have the following menu structure (created by WordPress, so can’t change the IDs/Classes) and I’d like to use JS 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.

Can anybody help me with the syntax?

<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>

So far I’m thinking that If I can get the class of the parent of the element that is being hovered over (I.e. ‘page_item page-item-10’ if the user hovers over ‘Ideas’) then I can set the background using the .hover() function. Not sure how to get that parent class though?

/**
 * 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');

    })
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:55:53+00:00Added an answer on May 28, 2026 at 8:55 pm

    I think this is what you need:

    $(function(){    
        $('#header-nav li ul.children li ul.children li a').hover(function(e){      
            $(this).parent().css('background-color', '#0066B5');
    
        }, function(){
            /** Reset the background of all matching elelments of 'mouseleave' */
            $('#header-nav li ul.children li').css('background-color', '#000');
    
        })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey Guys, i have created the following Menu Structure: <div id=menu> <ul> <li><a href=#>Main
I have a question. I use jquery superfish menu with the following structure <div
I have the following drop down menu and the background looks black in Chrome
I have a navigation menu in xHTML with the following typical structure: <ul id=nav1>
I have many INPUT tags with the following name structure: name=menu:popSearch:chk0 name=menu:popSearch:chk1 name=menu:popSearch:chk2 name=menu:popSearch:chk3
I have a menu with the following structure (simplified for illustration purposes): Menu Bar
Hello i have the following xml for menu i want to set the background
i have following menu structure and using the standard menu joomla module: menu top
Let's say we have the following menu structure: menu #1 menu #2 menu #3
I have a menu structure that looks like this: HTML: <li> <a href=#page> <b>Recover

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.