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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:09+00:00 2026-05-23T22:08:09+00:00

I have a vertical menu with sub categories. When a main category is clicked

  • 0

I have a vertical menu with sub categories. When a main category is clicked the sub-menu slides down and the previously opened sub-menu up slides up. I would like it if a user clicks on the same main-menu item a second time that it slides up the associated sub-menu. With this code it opens and closes it almost simultaneously when the same main menu item is clicked a second time.

$(".main-cat").click(function() {
    $(".active-sub").hide('slow');
    $(".sub" , $(this).parent()).toggle('slow');    
    $(".sub" , $(this).parent()).addClass('active-sub');
});

<div id="sidebar">
<ul>
    <li class="main">
        <div class="main-cat 1">Real Estate</div>
        <ul class="sub" id="sub_real_estate">
            <li><div class="sub-cat 2">Consulting Services</div></li>
            <li><div class="sub-cat 3">Investment</div></li>
            <li><div class="sub-cat 4">Property Management</div></li>
            <li><div class="sub-cat 5"> Development</div></li>
        </ul>
    </li>
    <li class="main">
        <div class="main-cat 6">Investment</div>
        <ul class="sub" id="sub_investment">
                <li><div class="sub-cat 7">Philosophy</div></li>
                <li><div class="sub-cat 8">Criteria</div></li>
          </ul>
        </li>
    </ul>
</div>
  • 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-23T22:08:10+00:00Added an answer on May 23, 2026 at 10:08 pm

    You can delay changes by assigning your code to an anonymous function that runs once the initial change has taken place, something like –

    $(".main-cat").click(function() {
        $(".active-sub").hide('slow', function () {
          $(".sub" , $(this).parent()).toggle('slow');    
          $(".sub" , $(this).parent()).addClass('active-sub');
        });
    });
    

    I’m not sure from your description if the above code will do the trick, but I thought the technique might help.

    EDIT

    Having looked at your HTML I think the code below should fix the problem (http://jsfiddle.net/WftqT/1/) –

    $(".main-cat").click(function() {
        //hide or show clicked menu
        $(".sub" , $(this).parent()).toggle('slow');
        //if clicked menu is now visible close all other open menus
        if (!$(".sub" , $(this).parent()).is(':hidden')) $(".maincat").not(this).parents('li').find('ul:[class="sub"]').hide('slow');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a vertical navigation menu compatibbel with jQuery UI ThemeRoller.
I have a vertical CSS sprite menu. I would like to realize a (at
I would like to have an iframe take as much vertical space as it
I have a side vertical menu, with sub pages (sub <ul> ). I have
we would like to know, How to create Vertical Navigation Menu in Wordpress. I
I have a small menu div that i would like to keep in the
i have web page it has a page header content like main menu,logo and
i have a menu like fllowing code Home Sub Item 1 Sub Item 1.1
I have a vertical menu in my system which is basically made of HTML
So I have a fairly simple vertical CSS menu based off of UL. <ul

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.