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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:29:21+00:00 2026-06-04T05:29:21+00:00

I have a table with months as header. When clicked on month i want

  • 0

I have a table with months as header. When clicked on month i want to display weeks in all tds of corresponding header. I am using toggle for this. How can I toggle back other elements when I click on a new header.

here is the fiddle. Here after first click it is taking two clicks to do the job. What is going wrong? Is there any other concise ways to do this.

  • 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-04T05:29:23+00:00Added an answer on June 4, 2026 at 5:29 am

    Something like this?

       $(document).ready(function() {
        $('th').click(
    
        function() {
            // hide all expanded
            $('#ex td #td_data').show();
            $('#ex td #o_data').hide();
    
            // show only corresponding weeks
            $('#ex td:nth-child(' + ($(this).index() + 1) + ')').each(function(index) {
                $(this).find('#td_data').hide();
                $(this).find('#o_data').show();
            });
    
        });
    
    });​
    

    EDIT:

    @Sami – I think I get your requirement now…

    Check the modifie fiddle here – http://jsfiddle.net/johnbk/JYkS6/

    -> I removed the css for #o_data

    -> id for each element should be unique – changed this to class instead

    -> Modified the above code like below

    $('.o_data').hide();
    $('.td_data').show();
    $('th').click(
    
    function() {
        var id = $(this).index() + 1;
    
         //loop through corresponding tds and display data
        $('#ex td:nth-child(' + id + ')').each(function(index) {
            $(this).find('.td_data').toggle();
            $(this).find('.o_data').toggle();
        });   
    
         //reset everything else
        $('#ex td').not(':nth-child(' + id + ')').each(function(index) {
            $(this).find('.td_data').show();
            $(this).find('.o_data').hide();
        });   
    
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mySQL table of events and want to display them in a
I have this table named OrdersToCall Data types: All bigints, except for date which
I have a table that has multiple payments occuring on different dates each month.
Say I have a table called HoursCharged ChrgNum(varchar(10)) CategoryID(uniqueidentifier) Month(datetime) Hours(int) CategoryID is a
I have a monthly table (only holds rows with first day of month, and
i have day, month, year, value columns in one table, here i need to
i have table structure with 3 colums (column1, column2, column3) and i want to
I have table with 3 columns A B C. I want to select *
I am using this javascript ( Super Table ) to transform my table in
I am trying to sort articles by Today, This Week, This Month , All

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.