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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:12:46+00:00 2026-06-08T09:12:46+00:00

I found a menu sample, and want to use it in my site. When

  • 0

I found a menu sample, and want to use it in my site. When mouse enter menu item, its style changes, but when mouse leave menu item, its style is as previous style. User doesn’t see which menu item is selected.
It is css code part:

  .navigation ul#topnav li{
        width:auto;
        float:left;
        padding:0;
        position:relative;
    }
    .navigation ul#topnav li a{
        color:#fff;
        background-color:inherit;
        padding:0 7px;
        text-align:center;
        display:block;
        border-left:5px solid transparent !important;
        border-right:5px solid transparent !important;
        position: relative;
        z-index: 50;
    }
    .navigation ul#topnav li a:hover{
        color:#824d97;
        background-color:inherit;
        background:url(../images/nav-hover-bg.png) repeat-x 0 0 !important;
        border-left:5px solid #6c1b93 !important;
        border-right:5px solid #6c1b93 !important;
    }

I want when mouse leave menu item after click, its style to be shown as hover, and user see which item is selected.

  • 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-06-08T09:12:47+00:00Added an answer on June 8, 2026 at 9:12 am

    Update your third CSS selector to something like:

    .navigation ul#topnav li a:hover, .navigation ul#topnav li a.selected {
    

    …so that those settings apply both to the <a> being hovered over and any <a> with the class “selected”. Or if you want the clicked link to have some variation on the hover styles add .navigation ul#topnav li a.selected { as a separate entry.

    Then in your JS code when a link is clicked you add the “selected” class to it and remove the class from any others:

    $("#topnav li a").click(function() {
        // whatever else you do on click, then
    
        $(this).addClass("selected");
        $("#topnav li a").not(this).removeClass("selected");
    });
    

    EDIT: Place that code in a $(document).ready() handler or in a script block at the end of the page.

    Working demo: http://jsfiddle.net/VFJ7c/

    Note: I was assuming (and I think the other answers assumed) that your menu was loading content via Ajax or showing and hiding existing content. If your menu has standard links that reload the entire page then this won’t work and you’ll need to either apply the “selected” class to the appropriate link in your server-side code or otherwise do it on DOM-ready rather than on click.

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

Sidebar

Related Questions

I found the Add Java Exception Breakpoint menu item but it only seems to
I like to use the XPStyle found in TActionManager to create my menu interface.
Maybe it is very simple, but I did found the solution. I just want
I've made a search in Google but not found any sample with a TreeView
i m trying to run the bluetooth chat sample from the developers site but
I want use WPF on Windows version of my java application. I found it
I want to use in GWT a menu widget (tutorial and code is here:
I am using the jQuery dynatree along with the context menu found here .
I found many css/js menu scripts on various sites they work well is in
I'd like to create a pop-up menu similar to the one found in the

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.