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

  • Home
  • SEARCH
  • 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 8883073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:43:38+00:00 2026-06-14T20:43:38+00:00

I recently found this expandable table with Jquery, it is very lightweight and awesome

  • 0

I recently found this expandable table with Jquery, it is very lightweight and awesome code. However, I need to make small changes to it, but I don’t know how. If you take a looks at this demo when you go clicking from the first row to the second, third, fourth…so on. The row just keeps on expanding, instead I need the in-active rows to contract. Meaning, when a user goes from click first row to second, then the previous one contracts..

I hope it is clear, and I would provide the code but you can see the source code, it is neat and Here is the full tutorial.

thanks.

Ok, here is the code in Jsfiddle:

    $(document).ready(function(){
        $("#report tr:odd").addClass("odd");
        $("#report tr:not(.odd)").hide();
        $("#report tr:first-child").show();

        $("#report tr.odd").click(function(){
            $(this).next("tr").toggle();
            $(this).find(".arrow").toggleClass("up");
        });
        //$("#report").jExpand();
    });

​

  • 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-14T20:43:40+00:00Added an answer on June 14, 2026 at 8:43 pm

    Here’s one approach, though I feel it could be somewhat simplified:

    $('#report tbody tr:nth-child(odd)').addClass('odd');
    $('#report tbody tr:nth-child(even)').addClass('even').hide();
    $('tr.odd').click(
        function(){
            var that = $(this),
                next = that.next('.even');
            that.find('.arrow').toggleClass('up');
            next.toggle().siblings('.even').hide();
            $('.even:not(":visible")').each(
                function(){
                    $(this).prev('.odd').find('.up').removeClass('up');
                });
        });
    

    JS Fiddle demo.

    References:

    • addClass().
    • each().
    • find().
    • hide().
    • :not() selector.
    • prev().
    • removeClass().
    • siblings().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently found this piece of example code from the GNU make documentation that
I just recently found myself writing this line of code, which i did not
EDIT 9-3-10: I found this blog entry recently that was very enlightening. http://optimizermagic.blogspot.com/2007/12/outerjoins-in-oracle.html There
This question is based off some really odd code I recently found in a
I recently found this piece of JavaScript code: Math.random() * 0x1000000 << 0 I
Working on existing code, I recently found smt like this: if(Config.ExceptionBehavior.DEBUG_EXCEPTIONS) { foo.Foo(); }
I recently found some code like this: typedef int TenInts[10]; void foo(TenInts &arr); What
I recently found this little piece of code for my .vimrc if has(autocmd) Highlight
I found this in some production login code I was looking at recently... HttpContext.Current.Trace.Write(query
Recently I was working with some JavaScript code and I found this: <script type=text/javascript>

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.