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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:43:35+00:00 2026-06-06T10:43:35+00:00

I have a problem and can’t find a solution. I am making an accordion

  • 0

I have a problem and can’t find a solution.
I am making an accordion menu in jquery and want the second level of the menu to open one at a time.

and would like to use this on a website any help in how to get this to stay open when the page reloads.

my first time asking so sorry if it is not readable.

hope anybody can help.

I am a noob in this kind of stuff.

$(document).ready(function(){
  menuHead = $('.slide-list li a').click(function() {
    $('.selected').removeClass('selected');
    $(this).addClass('selected');
    $(this).next().toggle("slow");
  });    
});
* {
  margin: 0;
  padding: 0;   
}

html, body {
  height: 100%;
  width: 100%;  
}

a:link {
  text-decoration:none;
  color: #000;
}

a:active {
  text-decoration:none;
  color: #000;
}

a:visitied {
  text-decoration:none;
  color: #000;  
}

a:hover {
  text-decoration:none;
  color: #CCC;
}


#menu-wrapper {

}

#menu-wrapper ul.slide-list li {
  list-style-type: none;    
}

#menu-wrapper ul.slide-list li a.selected {
  color: #F00;  
}

#menu-wrapper ul.slide-list li ul {
  display: none;    
}

#menu-wrapper ul.slide-list li ul li ul {
  display: none;    
}
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="menu-wrapper">
  <ul class="slide-list">
    <li>
        <a href="javascript:void()">menu item 1</a>
          <ul>
            <li>
                <a href="javascript:void()">submenu item 1 level 2</a>
                  <ul>
                    <li>
                        <a href="javascript:void()">submenu item level 3</a>
                      </li>
                  </ul>
              </li>
              <li>
                <a href="javascript:void()">submenu item 2 level 2</a>
                  <ul>
                    <li>
                        <a href="javascript:void()">submenu item level 3</a>
                      </li>
                  </ul>
              </li>
          </ul>
      </li>
      <li>
        <a href="javascript:void()">menu item 2</a>
          <ul>
            <li>
                <a href="javascript:void()">submenu item 1 level 2</a>
              </li>
          </ul>     
      </li>
    <li>
        <a href="javascript:void()">menu item 3</a>
      </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-06-06T10:43:40+00:00Added an answer on June 6, 2026 at 10:43 am

    Try this

    if(window.location.hash.length > 0){
      var $licurrent = $($('.slide-list li').get(window.location.hash.replace('#','')));
      $licurrent.parents("ul").show();
      $licurrent.find("ul:first").show();
      $licurrent.find("a:first").addClass("selected");
    }
    
    $(document).ready(function(){
      $('.slide-list li a').click(function(e) {                     
          e.preventDefault();
          $('.selected').removeClass('selected');
          $(this).addClass('selected');
    
          var $licurrent = $(this).parent();
          window.location.hash = $('.slide-list li').index($licurrent);
    
          $licurrent.parent().find("li").not($licurrent).find("ul").hide("slow");
          $(this).next("ul").toggle("slow");
      });
    });
    * {
      margin: 0;
      padding: 0;    
    }
    
    html, body {
      height: 100%;
      width: 100%;    
    }
    
    a:link {
      text-decoration:none;
      color: #000;
    }
    
    a:active {
      text-decoration:none;
      color: #000;
    }
    
    a:visitied {
      text-decoration:none;
      color: #000;    
    }
    
    a:hover {
      text-decoration:none;
      color: #CCC;
    }
    
    
    #menu-wrapper {
    
    }
    
    #menu-wrapper ul.slide-list li {
      list-style-type: none;  
    }
    
    #menu-wrapper ul.slide-list li a.selected {
      color: #F00;    
    }
    
    #menu-wrapper ul.slide-list li ul {
      display: none;  
    }
    
    #menu-wrapper ul.slide-list li ul li ul {
      display: none;  
    }
    <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <div id="menu-wrapper">
      <ul class="slide-list">
          <li>
              <a href="javascript:void()">menu item 1</a>
              <ul>
                  <li>
                      <a href="javascript:void()">submenu item 1 level 2</a>
                      <ul>
                          <li>
                              <a href="javascript:void()">submenu item level 3</a>
                              <ul>
                                <li>
                                    <a href="javascript:void()">submenu item level 4</a>
                                </li>
                              </ul>
                          </li>
                      </ul>
                  </li>
                  <li>
                      <a href="javascript:void()">submenu item 2 level 2</a>
                      <ul>
                          <li>
                              <a href="javascript:void()">submenu item level 3</a>
                          </li>
                      </ul>
                  </li>
              </ul>
          </li>
          <li>
              <a href="javascript:void()">menu item 2</a>
              <ul>
                  <li>
                      <a href="javascript:void()">submenu item 1 level 2</a>
                  </li>
              </ul>     
          </li>
          <li>
              <a href="javascript:void()">menu item 3</a>
          </li>
      </ul>
    </div>

    This code will add the hash in URL and when you refresh the page you could find that menu selected.

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

Sidebar

Related Questions

I have a problem which i can't seem to find the solution to. I
I have a problem and can't solve it alone. My teacher gives me one
I'm almost finished with my program, but I have one problem that I can't
I have a weird problem that i can't figure out a solution for: I've
I have a problem i can't find the wrong in this function it sometimes
I have a problem and can't find information. I run my web-app from jsp-page
i have problem i can't solve for a while. For one of my C++
i have a c problem can any one help me . i wrote a
I have another problem I can't seem to solve..., or find on this site...
I have a problem i can't find the wrong in this function it sometimes

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.