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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:28:44+00:00 2026-06-18T04:28:44+00:00

Here i made an example of my menu jsfiddle . So i have horizontal

  • 0

Here i made an example of my menu jsfiddle. So i have horizontal menu with drop down, but what i need is – on page load first li should be expanded(this is not hard) and when i hover on any other element it should display current expanded content(and if i mouseleave current element should be expanded).

This is the situation when i hover on Item2 and mouseleave Item2 it should stay like this:

Item1       Item2          Item3
            |||||
subItem2.1  subItem2.2 subItem2.3

UPDATE:

i managed to do it, but with exception, here is the link on JSFiddle

Its works as i wanted, but when i click on a link Item1 , or Item2 , init() function is called, and Item1 , active again, i need somehow to set active link – clicked one,

for example if i clicked on a Item3 link it redirects me to Item3 page and this link is active in menu.
(all code on Jsfiddle)

  • 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-18T04:28:45+00:00Added an answer on June 18, 2026 at 4:28 am

    If I understand your question correctly, the problem is that you need to call the init function to redraw all, but at the same time you set there item1 as current; and this is not ok if you have just pressed link2.

    If think that your solution should be to almost remove all the init code. All this can be done in the css styles, simplifying a lot your code.

    you set active to items. (You are already doing this in the anchors, do it in the li). Then, put all the appearance styles inn the css, and your script is reduced.

    don’t need to set active on subitems. you can set rules like li.active li; that is, the li that is descendant of the active li.

    Once you do all this, you can avoid the init funcion altogether.

    Added fiddle

    I have changed that in the updated fiddle

    I am marking the visible item menu ‘current’, I find ‘active’ confusing for a class name. It must be in the li and not in the, so that it can affect the second level lis

    Now the script is just

    $(document).ready(function() {
        $("#menu_item ul.menu li.expanded").mouseover(function(){
            var previous = $('.current');
            previous.removeClass('current');          
            $(this).addClass('current');
        });
    });
    

    I am just removing current from the previous current element, and adding it to the new one.

    The initial selection is just in the markup

    <div id="menu_item">
        <ul class="menu">
            <li class="expanded first current">
            <a href="#" title="">Item1</a>
    

    And the new css rules are:

    #menu_item > ul.menu > li.current  {
        background-color: orange;
    }
    #menu_item ul.menu li ul {
        display: none;
    }
    #menu_item ul.menu li.current ul {
        display: block;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have this dropdown made in html/css/js.. it slides down on mouseover, but
I need some help to understand pushStack Here I've made an example where the
my question is that I have made multimap.Here is the partial code. if(binary_search(final.begin() ,
Here's what I have: Custom-made C# CMS where the content is stored in a
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have made a dropdown menu that uses tabs to display the specific content
I have a menu made with HTML, using a simple UL with lots of
I have made this question: Menu with 2 levels disapear the background and that's
I have a nav bar that has a dropdown menu made with styled tags.
I am trying to create a multi level drop down menu hopefully using PHP

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.