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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:27:43+00:00 2026-05-15T21:27:43+00:00

First question ever asked at stackoverflow. So, problem is: Two accordion declarations on document.ready

  • 0

First question ever asked at stackoverflow.
So, problem is:
Two accordion declarations on document.ready (jquery 1.4.2 and jquery ui 1.8.2):

       $(document).ready(function () {
        $("#accordion").accordion({
            header: 'h3'
        });

        $("#accordion2").accordion({ 
            header: 'h4' 
        });

        $(function () {
            $(".get-index").click(function () {
                var activecontent = $("#accordion").accordion("option", "active");
                alert(activecontent);                   
            });
        });
    });

HTML:

<div id="accordion">
    <h3><a href="#">Section 1</a></h3>
    <div>
        Content Section 1: Parent
        <div id="accordion2">
            <h4><a href="#">SubSection 1</a></h4>
            <div>content section 1: child</div>
            <h4><a href="#">SubSection 2</a></h4>
            <div>content section 2: child</div>
            <h4><a href="#">SubSection 3</a></h4>
            <div>content section 3: child</div>
            <h4><a href="#">SubSection 4</a></h4>
            <div>content section 4: child</div>
        </div>
    </div>
    <h3><a href="#">Section 2</a></h3>
    <div>
        Content Section 2: Parent
    </div>
    <h3><a href="#">Section 3</a></h3>
    <div>
        Content Section 3: Parent
    </div>
    <h3><a href="#">Section 4</a></h3>
    <div>
        Content Section 4: Parent

        <button type="button" class="get-index ui-button ui-button-text-only ui-widget ui-state-default ui-corner-all">
            <span class="ui-button-text">index</span>
        </button>

    </div>
</div> 

And finally: what’s wrong and why “activecontent” is 7? I know, that there are 4 parent panels + 4 child panels and starting from 0, it is 7. But I’m trying to get index of last parent panel and it should be 3.

Any help much appreciated.

Code posted: http://jsbin.com/eqewe

  • 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-15T21:27:44+00:00Added an answer on May 15, 2026 at 9:27 pm

    Unfortunately this is a bug in jQuery UI, in the accordion code:

    o.active = o.collapsible && clickedIsActive ? false 
      : $('.ui-accordion-header', this.element).index(clicked);
    

    It’s finding any $('.ui-accordion-header'), not just the header selector you specified and not only immediate children. I’ll put this in as a bug with the jQuery UI guys, the .active property really should be set differently. I’ve entered a bug with the jQuery UI team for this here: http://dev.jqueryui.com/ticket/5841


    You can work-around it for now by finding the element yourself with .index(), like this:

    $(function () {
      $(".get-index").click(function () {
        var a= $("#accordion").children('.ui-state-active').index('#accordion > h3');
        alert(a);                   
      });
    });​
    

    You can try it out here

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

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is no problem with this unless you use a… May 16, 2026 at 3:32 pm
  • Editorial Team
    Editorial Team added an answer If you have a SharedPreferences.Editor object and you call clear(),… May 16, 2026 at 3:32 pm
  • Editorial Team
    Editorial Team added an answer I use URL Rewrite for this. You can download/install here:… May 16, 2026 at 3:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I asked a similar question like this yesterday but after waiting for ever I
(I am sorry, I wanted to ask this question on meta first, but it
Ever since I asked how to parse html with regex and got bashed a
I am working on a .net project, (first ever for me) and I would
I'm using two threads in an iPhone app for the first time and I've
I've been asked to find out what several of the default icons in Umbraco
While interviewing for a company, I was asked to submit several code samples that
this is my first time using Eclipse, and my first time programming in a
Just wondering if anyone has ever converted a Websphere project to run under tc
Ok, it's my fault. I've never ever learned programming at a school and that's

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.