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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:04:11+00:00 2026-05-11T05:04:11+00:00

I have a menu implemented using a set of nested accordions, 1 and 2

  • 0

I have a menu implemented using a set of nested accordions, 1 and 2, each with elements, a and b.

I would like to implement the following logic:

  • When I click 1a, I will get the data of 1a and two submenu 2a,2b

  • When I click 2a, 2b I will get the data of each, respectively.

The problem

Desired result:

  • I only want to display the nth-most child element for the last click, collapsing all others.
  • Upon initialization, only 1a and 1b should be visible.

Current result:

  • Clicking on 1b, then on 2b, 1b is still fully visible.

JavaScript code

$(document).ready(function() {     $("#acc1").accordion({         active:".ui-accordion-left",         alwaysOpen: false,         autoheight: false,         header: 'a.acc1',         clearStyle: true     });     $("#acc2").accordion({         alwaysOpen: false,         autoheight: false,         header: 'a.acc2',         clearStyle: true     }); }); 

HTML:

<ul id="acc1" class="ui-accordion-container">     <li>         <div class="ui-accordion-left"></div>         <a class="ui-accordion-link acc1">1a             <span class="ui-accordion-right"></span>         </a>         <div>             data of 1a<br/>             data of 1a<br/>             data of 1a<br/>         </div>         <div>             <ul class="ui-accordion-container" id="acc2">                 <li>                     <div class="ui-accordion-left"></div>                     <a class="ui-accordion-link acc2">2a                         <span class="ui-accordion-right"></span>                     </a>                     <div>                         data of 2a<br/>                         data of 2a<br/>                         data of 2a<br/>                     </div>                 </li>                 <li>                     <div class="ui-accordion-left"></div>                     <a class="ui-accordion-link acc2">2b                         <span class="ui-accordion-right"></span>                     </a>                     <div>                         data of 2b<br/>                         data of 2b<br/>                         data of 2b<br/>                     </div>                 </li>             </ul>         </div>     </li>     <li>         <div class="ui-accordion-left"></div>         <a class="ui-accordion-link acc1">1b             <span class="ui-accordion-right"></span>         </a>         <div>             data of 1b<br />             data of 1b<br />             dta of 1b <br />         </div>     </li> </ul> 
  • 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. 2026-05-11T05:04:11+00:00Added an answer on May 11, 2026 at 5:04 am

    Just a few changes to the order of the elements in your HTML and you get the behavior you are looking for. At the start now only 1a and 1b are open. Similarly when you click on 1b now it will close 1a which will hide any open 2a/2b section as well.

        $(document).ready(function() {         $('#acc1').accordion({             active:'.ui-accordion-left',             alwaysOpen: false,             autoheight: false,             header: 'a.acc1',             clearStyle: true         });         $('#acc2').accordion({             active:'.ui-accordion-left',             alwaysOpen: false,             autoheight: false,             header: 'a.acc2',             clearStyle: true         });     });      <ul id='acc1' class='ui-accordion-container'>         <li>             <div class='ui-accordion-left'>             </div>             <a class='ui-accordion-link acc1'>1a                 <span class='ui-accordion-right'></span>             </a>             <div>                 data of 1a<br/>                 data of 1a<br/>                 data of 1a<br/>                 <ul class='ui-accordion-container' id='acc2'>                     <li>                         <div class='ui-accordion-left'>                         </div>                         <a class='ui-accordion-link acc2'>2a                             <span class='ui-accordion-right'></span>                         </a>                         <div>                             data of 2a<br/>                             data of 2a<br/>                             data of 2a<br/>                         </div>                     </li>                     <li>                         <div class='ui-accordion-left'>                         </div>                         <a class='ui-accordion-link acc2'>2b                         <span class='ui-accordion-right'></span></a>                         <div>                             data of 2b<br/>                             data of 2b<br/>                             data of 2b<br/>                         </div>                     </li>                 </ul>             </div>         </li>         <li>             <div class='ui-accordion-left'></div>             <a class='ui-accordion-link acc1'>1b             <span class='ui-accordion-right'></span></a>             <div>                 data of 1b<br />                 data of 1b<br />                 dta of 1b <br />             </div>         </li>     </ul> </body> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement Menu in a Window using MVVM pattern. So I have
I have to implement a menu with icons using actionscript only. I create a
I have a menu bar and I want to create a div for each
I have implemented a javascript menu allowing users to change to different map views
I have idea to implement my wpf windows like TabPages in tab control. It
I have implemented a WebApp using SplitView - http://asyraf9.github.com/jquery-mobile/ - (and that seems to
I have implemented a dynamic creation of a HTML table using AJAX. Here's what
I have implemented my own drop down menu and wanted to clarify the accessibility
I'm trying to implement Mega Menu style menus using WPF. To see examples of
I'm using AndEngine to create a Live Wallpaper and I have everything set up

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.