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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:57:56+00:00 2026-05-16T08:57:56+00:00

When using jQuery’s Accordion (in a nested fashion), I want to ensure that when

  • 0

When using jQuery’s Accordion (in a nested fashion), I want to ensure that when a parent element is clicked/opened, any open children are closed/rolled up. I’m not sure what selector(s) I should use when attempting to do this. So far I’ve tried rigging a change event with “activate” set to false, but that simply makes any element that is opened automatically close.

Assuming I only have 1 nested accordion, my jquery initialization looks like:

$(".accordion").accordion({
            active: false, collapsible: true, autoHeight: false, animated: 'swing'
        });

        $(".child-accordion").accordion({
            active: false, collapsible: true, autoHeight: false, animated: 'swing',
            change: function(event, ui) { $(".child-accordion").accordion("activate", false); }
        });

where .child-accordion is the nested instance. I need anything under the .child-accordion to be closed when a member of the .accordion is opened.

  • 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-16T08:57:57+00:00Added an answer on May 16, 2026 at 8:57 am
    $(".accordion").accordion({
        collapsible: true,
        autoHeight: false,
        animated: 'swing',
        changestart: function(event, ui) {
            child.accordion("activate", false);
        }
    });
    
    var child = $(".child-accordion").accordion({
        active:false,
        collapsible: true,
        autoHeight: false,
        animated: 'swing'
    });
    

    The reason your version wasn’t working is two-fold

    1. Your change event needs to be on the parent, because that’s when you want the children to roll up

    2. You need to make the event changestart because when you set activate to false, the main thing it does is toggle the currently “visible” section in the child, but when the change event triggers on the parent, the child is already hidden, so it doesn’t do anything.

    EDIT: here’s a working version of this http://jsfiddle.net/ryleyb/YPpEn/

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

Sidebar

Related Questions

Using jQuery, how can I get the input element that has the caret's (cursor's)
Using jQuery the child elements of the #parent element are to be fetched with
using jquery's .post i send do my php code an object that with var_dump
Using jQuery Nearest Element , I would like to select elements in a circular
Using jQuery, is there a way to disable the click sound in IE that
Using jquery, how can I find the first div that contains an input with
Using jQuery, I want to check if the text of a link I'm clicking
Using JQuery how to check if any checkboxes are checked and then set the
(using jquery) I have the following function $(function() { $('tr.parent') .css(cursor,pointer) .attr(title,Click to expand/collapse)
Using jQuery validation - validating on blur: $('input, select, radio, checkbox').blur(function(){ $(#createAccount).validate().element(this); }); If

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.