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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:24:54+00:00 2026-05-24T17:24:54+00:00

Before going into my problem, I will post reference where I found partial solution:

  • 0

Before going into my problem, I will post reference where I found partial solution:

  • Here is the answer to my similar problem

Now first I will post my whole example on jsFiddle, stripped down of unnecessary stuff:

  • My example

I will also post the code here:

  • HTML:

<ol class="decimalListFirstOl">
<li class="decimalListLi">
    Test1
    <ol class="decimalListSecondOl">
         <li class="columns decimalListLi">
            Test1<span class="show">+</span>
            <div class="hide">
                <ul class="defaultFont">
                    <li>Test1</li>
                    <li>Test2</li>
                    <li>...</li>
                </ul>
            </div>
        </li>
        <li class="columns decimalListLi">
            Test2
            <span class="show">+</span>
            <div class="hide">
                <ul class="defaultFont">
                    <li>Test1</li>
                    <li>Test2</li>
                    <li>...</li>
                </ul>
            </div>
        </li>
        <li class="columns decimalListLi">
            Test3
            <span class="show">+</span>
            <div class="hide">
                <ul class="defaultFont">
                    <li>Test1</li>
                    <li>Test2</li>
                    <li>...</li>
                </ul>
            </div>
        </li>
    </ol>
</li>

  • CSS:

.hide {
display: none;
}
.columns {
    float: left;
    width: 33%;
}
.decimalListLi {
    color: #627490;
    display: block;
}
.decimalListLi:before {
    content: counters(item, ".") " ";
    counter-increment: item;
}
.decimalListFirstOl {
    counter-reset: item;
    font-size: 17px;
    font-weight: bold;
    padding-left: 0;
}
.decimalListSecondOl {
    counter-reset: item;
    font-size: 15px;
    font-weight: normal;
    padding-left: 25px;
}
.defaultFont {
    color: #525252;
    font-family: Tahoma, Arial, Helvetica, Sans-Serif;
    font-size: 12px;
}
  • JAVASCRIPT/JQUERY:

$(document).ready(function() {
    $('.show').click(function() {
        var index = $(this).index();
        $('.hide').eq(index).slideToggle("slow").siblings('.hide').hide();
    });
});

I am using jQuery 1.6.2. I want that one click on the sign(+), closes currently opened column and the clicked column opens (slides down). I have already achieved the opening and closing, but for some reason it always opens and closes the first column, no matter which + is clicked. Now I have followed the answer on first link, but the problem is, I have nested ol and li and that’s why probably this line of code:

var index = $(this).index();

for some reason always returns 0! Which means it will always open and close the first column.

  • 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-24T17:24:55+00:00Added an answer on May 24, 2026 at 5:24 pm

    your toggle buttons are index ‘0’ cause their .index() is referenced to ‘index of element in parent’ And there’s only 1 ‘.show’ inside ‘his’ li parent.

    So just look for the parent index() using

     var index = $(this).parent().index(); 
    

    AND HERE IS A DEMO TO TOGGLE ALREADY OPENED MENUS:

    DEMO

    $(document).ready(function() {
        $('.show').click(function() {
            var index = $(this).parent().index();
            $('.hide').hide();
            $('.hide').eq(index).slideToggle("slow");      
        });
    });
    

    You can use this solution too ( using .next('.hide') It will look for the next element .hide) :

    $(document).ready(function() {
        $('.show').click(function() {
            $('.hide').hide();
            $(this).next('.hide').slideToggle();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I start, I know there is this post and it doesn't answer my
this is my very first post! I'm pretty desperate so I'm going above and
I just finished a little 5000-line PHP application and are now going into testing
Before you answer this I have never developed anything popular enough to attain high
Before I jump headlong into C#... I've always felt that C, or maybe C++,
Before, I have found the Cost in the execution plan to be a good
Before you answer, this question is complicated: We are developing in asp.net / asp.net
I've ran into a really weird problem while working on a large project. I
I am getting a weird problem while using scanf() to store data into a
I know Joomla 1.6 is now released, but curious if there will be an

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.