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 635643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:25:37+00:00 2026-05-13T20:25:37+00:00

I have a navigation that uses jQuery and CSS to control image mouseover positioning

  • 0

I have a navigation that uses jQuery and CSS to control image mouseover positioning and dropdown menus. Everything works as it should. I have a request from the client though to make one modification.

You can see the example here: http://www.rouviere.com/jr/index.html (best viewed in Firefox or Safari right now)

If you mouse over the links the gold turns to green, however if you mouse over the drop down menu items the parent link changes back to gold. My client would like to have the parent link stay green. So my question is, how do I achieve that?

Here is the css for the parent link mouse over:

ul.dropdown li a.home:hover,
ul.dropdown li a.about:hover,
ul.dropdown li a.portfolio:hover,
ul.dropdown li a.maintenance:hover,
ul.dropdown li a.testimonials:hover,
ul.dropdown li a.contact:hover    { background-position: center center; }

Here is the navigation code:

        <ul class="dropdown">
    <li><a class="home" href="#">Home</a></li>
        <li><a class="about" href="#">About Us</a>
            <ul class="sub_menu">
                 <li><a href="#">Our History</a></li>
                <li><a href="#">Our Process</a></li>
                <li><a href="#">Portfolio</a></li>
                <li><a href="#">Financing</a></li>
                <li><a href="#">Testimonials</a></li>
                <li><a href="#">Subcontractors</a></li>
            </ul>
        </li>
        <li><a class="portfolio" href="#">Portfolio</a>
            <ul class="sub_menu">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
                <li><a href="#">Item 3</a></li>
            </ul>
        </li>
        <li><a class="maintenance" href="#">Maintenance</a>
            <ul class="sub_menu">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
                 <li><a href="#">Item 3</a></li>
            </ul>
        </li>
        <li><a class="testimonials" href="#">Testimonials</a>
            <ul class="sub_menu">
                <li><a href="#">Item 1</a></li>
                <li><a href="#">Item 2</a></li>
                 <li><a href="#">Item 3</a></li>
            </ul>
        </li>
        <li><a class="contact" href="#">Contact Us</a></li>
    </ul>

And last but not least here is the jQuery:

$(function(){

$("ul.dropdown li").hover(function(){

    $(this).addClass("hover");
    $('ul:first',this).css('visibility', 'visible');

}, function(){

    $(this).removeClass("hover");
    $('ul:first',this).css('visibility', 'hidden');

});

$("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

});

Thanks in advance for the help!

  • 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-13T20:25:37+00:00Added an answer on May 13, 2026 at 8:25 pm

    Why are you using jQuery to do what CSS lets you do? I think that if you use the following selectors:

    ul.dropdown li a.home:hover,
    ul.dropdown li:hover { /* this targets the parent li's default hover state set it to the green colour */ }
    
    ul.dropdown li ul li:hover,
    ul.dropdown li ul li a:hover { /* this targets the dropdown li's default state set this to gold */ }
    

    It should work.


    Edited in response to comment

    Demo site seems stable, on Chrome, Firefox and Opera, found over at: http://davidrhysthomas.co.uk/so/parentLiStyles.html, please excuse the ugly. It’s functional, not pretty… =/


    Edited to bring the accepted code inline
    I figure, at some point, that I might tidy up my site, and the code might be more useful here anyway. So here it is, in its entirety:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>list styling demo-page for Stackoverflow.com question 1517220</title>
        <link rel="stylesheet" type="text/css" href="css/stylesheet.css" />
    
        <style type="text/css" media="all">
    
        ul.dropdown     {width: 60%;
                        max-width: 100em;
                        margin: 1em auto;
                        }
    
        ul.dropdown li      {display: inline-block;
                        position: relative;
                        padding: 0 1em;
                        color: #fff;
                        background-color: #a18524;
                        }
    
        ul.dropdown li.hover    {background-color: #a18524;
                        }
    
        ul.dropdown li a    {text-decoration: none;
                        display: block;
                        color: #fff;
                        background-color: transparent;
                        }
    
        ul.dropdown li:hover,
        ul.dropdown li a:hover  {color: #fff;
                        background-color: #41602a;
                        }
    
        ul.dropdown li ul   {display: none;
                        position: absolute;
                        top: 1em;
                        left: 0;
                        }
    
        ul.dropdown li:hover ul
                        {display: block;
                        }
    
        ul.dropdown li ul li    {display: block;
                        border-bottom: 1px solid #fff;
                        line-height: 1.4em;
                        }
    
        ul.dropdown li ul li a  {width: 10em;
                        border
                        }
    
        #code           {white-space: pre-wrap;
                        width: 60%;
                        max-width: 100em;
                        margin: 1em auto;
                        line-height: 1.2em;
                        font-family: consolas, mono;
                        }
    
        </style>
    
        <script type="text/javascript" src="js/jquery.js"></script>
    
    </head>
    
    <body>
    
           <ul class="dropdown">
        <li><a class="home" href="#">Home</a></li>
            <li><a class="about" href="#">About Us</a>
                <ul class="sub_menu">
                     <li><a href="#">Our History</a></li>
                    <li><a href="#">Our Process</a></li>
                    <li><a href="#">Portfolio</a></li>
                    <li><a href="#">Financing</a></li>
                    <li><a href="#">Testimonials</a></li>
                    <li><a href="#">Subcontractors</a></li>
                </ul>
            </li>
            <li><a class="portfolio" href="#">Portfolio</a>
                <ul class="sub_menu">
                    <li><a href="#">Item 1</a></li>
                    <li><a href="#">Item 2</a></li>
                    <li><a href="#">Item 3</a></li>
                </ul>
            </li>
            <li><a class="maintenance" href="#">Maintenance</a>
                <ul class="sub_menu">
                    <li><a href="#">Item 1</a></li>
                    <li><a href="#">Item 2</a></li>
                     <li><a href="#">Item 3</a></li>
                </ul>
            </li>
            <li><a class="testimonials" href="#">Testimonials</a>
                <ul class="sub_menu">
                    <li><a href="#">Item 1</a></li>
                    <li><a href="#">Item 2</a></li>
                     <li><a href="#">Item 3</a></li>
                </ul>
            </li>
            <li><a class="contact" href="#">Contact Us</a></li>
        </ul>
    
    
    <div id="code">
        ul.dropdown     {width: 60%;
                        max-width: 100em;
                        margin: 1em auto;
                        }
    
        ul.dropdown li      {display: inline-block;
                        position: relative;
                        padding: 0 1em;
                        color: #fff;
                        background-color: #a18524;
                        }
    
        ul.dropdown li.hover
                        {background-color: #a18524;
                        }
    
        ul.dropdown li a    {text-decoration: none;
                        display: block;
                        color: #fff;
                        background-color: transparent;
                        }
    
        ul.dropdown li:hover,
        ul.dropdown li a:hover
                        {color: #fff;
                        background-color: #41602a;
                        }
    
        ul.dropdown li ul   {display: none;
                        position: absolute;
                        top: 1em;
                        left: 0;
                        }
    
        ul.dropdown li:hover ul
                        {display: block;
                        }
    
        ul.dropdown li ul li    {display: block;
                        border-bottom: 1px solid #fff;
                        line-height: 1.4em;
                        }
    
        ul.dropdown li ul li a
                        {width: 10em;
                        border
                        }
    </div>
    
    </body>
    
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a custom navigation webpart that uses the PortalSiteMapProvider of MOSS to build
I have the following jQuery code that uses the scrollTo and localScroll plugins from
I have a jQuery based accordion style navigation that I am trying to modify.
I am developing a WordPress page that uses a jquery.slideto.js navigation system and html
I have a navigation view with a cell that has something as simple as
I have a small tabbed navigation setup using CSS. When hovering over the tabs
I have created some rounded navigation tabs using CSS and am having trouble when
I am trying to make a navigation that uses simple unordered lists to list
I have a site which uses a lot of JavaScript (mainly jQuery) and I
I have a navigation menu that has submenus slide down on hover. The menu

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.