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

  • Home
  • SEARCH
  • 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 6986777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:51:09+00:00 2026-05-27T18:51:09+00:00

I’m looking to highlight the second level parent of a navigation bar when hovering

  • 0

I’m looking to highlight the second level parent of a navigation bar when hovering over any of it’s children; the top level has completely different styling so doesn’t apply to what I’m trying to do, so when I hover over any of the third level items I want to style the second level. I understand javascript/jquery is the way to go for this so as my skills aren’t up to scratch I’ve hit a brick wall.

Here’s my standard html navigation structure:

<nav class="primary-navigation">
     <ul>
         <li><a href="#">TOP LEVEL</a>
             <ul>
                 <li><a href="#">SECOND LEVEL</a>
                     <ul>
                         <li><a href="#">THIRD LEVEL</a></li>
                         <li><a href="#">THIRD LEVEL</a></li>
                         <li><a href="#">THIRD LEVEL</a></li>                    
                     </ul>
                 </li>
             </ul>
         </li>
     </ul>
</nav>

I’ve been trying to work without classes, but I’ve been having trouble with selecting the li items without them, ideally if it’s possible I’d like to learn how to do it without them.

Here’s how far I’ve gotten so far, but it seems to add the ‘highlighted’ class to all the children as well, but I just want to apply it to the parent item!

$('THIRD LEVEL').mouseenter(function() {
      $(this).parent().closest('SECOND LEVEL').addClass('highlighted');
  }).mouseleave(function() {
      $(this).parent().closest('SECOND LEVEL').removeClass('highlighted');
  });

Thanks in advance

  • 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-27T18:51:09+00:00Added an answer on May 27, 2026 at 6:51 pm

    The problem is, that you use the highlight class on the complete li element. If you add highlighted only to the link it works.

    $('.third').mouseenter(function() {
        $(this).parent().find('a.second').addClass('highlighted');
    }).mouseleave(function() {
        $(this).parent().find('a.second').removeClass('highlighted');
    });
    

    Working example here: http://jsfiddle.net/VqcKu/7/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I would like to count the length of a string with PHP. The string

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.