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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:08:19+00:00 2026-05-28T11:08:19+00:00

i have simple side menu with this html code : <div id=menu> <div> Menu

  • 0

i have simple side menu with this html code :

<div id="menu">
                    <div>
                        Menu Title
                    </div>
                    <ul class="menu">
                        <li>
                            <span>
                                first item
                            </span>
                            <ul>
                                <li>
                                    sub item
                                </li>
                                <li>
                                    sub item
                                </li>
                                <li>
                                    sub item
                                </li>
                            </ul>
                        </li>
                        <li>
                            <span>
                                second item
                            </span>
                            <ul>
                                <li>sub menu</li>
                                <li>sub menu</li>
                            </ul>
                        </li>
                        <li>
                            <span>
                                third item
                            </span>
                            <ul>
                                <li>
                                    sub menu
                                </li>
                                <li>
                                    sub menu
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>

and css is :

#menu{
text-align:center;
font-size:13px;
font-family:tahoma;
color:#0000AA;
padding:2px 0;}
#menu div{
color:#0000AA;}
#menu ul{
text-align:right;
background-color: #FFFFFF;
list-style-type: none;
margin: 0px;
padding: 0px;}
#menu ul li{
display:block;
margin: 3px 2px;
cursor:hand;
cursor:pointer;}
#menu ul li span{
width:100%;
display:block;
background-color:#DDDDFF;}
#menu ul li span:hover{
background-color:#9999EE;}
#menu ul li ul{
display:none;}
#menu ul li ul li{
background-color:#EEEEEE;
margin:2px;
display: block;}
#menu ul li ul li:hover{
background-color:#FFFFFF;}
.submenu{
background-color: #CCCCFF;}  

and jquery code is :

    $(window).load(function(){
  $(".submenu").children(this).slideUp("slow");
});
$(document).ready(function(){
    $('ul.menu li span').click(function(){
    $("ul.menu li").find('ul').slideUp('fast');
    $(this).parent(this).find('ul').slideDown('fast');
    });
});

and my complate menu locate in http://jsfiddle.net/parseha/NkuG5/3/
this problem is : when clicking first item , sub menus sliding up and then sliding down , i want do not this run .
excuse me for this text and my mistake in content.
thanks.

  • 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-28T11:08:19+00:00Added an answer on May 28, 2026 at 11:08 am

    The trick is to keep a track of which menu is expanded, and depending on its state (expanded or collapsed) determine what action to take (slide up or slide down).

    You can achieve this by adding a class to the menu item when it is expanded, and remove that class when it is collapsed. Existence of that class will indicate whether the menu is expanded or collapsed.

    Jquery code:

    $(window).load(function() {
        $(".submenu").children(this).slideUp("slow");
    });
    $(document).ready(function() {
        $('ul.menu li span').click(function() {
            if ($(this).hasClass('current'))
            {
                $(this).removeClass('current');
                $("ul.menu li").find('ul').slideUp('fast');
    
            }
            else
            {
                $(this).addClass('current');
                $(this).parent(this).find('ul').slideDown('fast');            
    
            }
        });
    });
    

    Demo

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

Sidebar

Related Questions

I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have a simple html doc with a flex app and an iframe side-by-side
Let's say I have a simple CSS layout and my menu is a column
I a template, I have five DIV elements underneath each other on a HTML
I'm designing a simple Cocoa app. This is basically my second Cocoa app (despite
I have a simple object that is deserialized from JSON into a server-side object.
I have a simple function that I want to call in the code behind
How do you create a layout where you have a fixed-width side-menu but the
I have a side menu on my site that i would like always visible.
I have a side menu that I want to to have the Admin option

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.