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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:10:03+00:00 2026-05-20T08:10:03+00:00

Sorry if the title doesn’t make sense, basically I have a bunch of table

  • 0

Sorry if the title doesn’t make sense, basically I have a bunch of table rows like this:

<table>
<tr class="odd">
<td><button class="button_clicked">Hide row</button></td>
</tr>
<tr class="even">
<td><button class="button_clicked">Hide row</button></td>
</tr>
<tr class="odd">
<td><button class="button_clicked">Hide row</button></td>
</tr>
<tr><td class="notes"</td></tr>
</table>

Each tr has a class, odd is a white background and even have a gray background. Im using jquery that says if a button in one of the td is clicked then hide the entire tr row where the button was clicked. Some table rows have an additional tr right after it for notes, so the jquery detects if that is present as well, if so remove that tr as well. But the issue now is if I hide a tr that has a gray background the table row below it comes up and now I have 2 table rows that are white and breaks the odd/even design of the table rows. So I tried writing additional code below to do additional check but it stops the script from working. It doesnt give me an error, it just shows the script as aborted, any suggestions?

        $('.button_clicked').click( function(e) {

        var row = $(this).closest('tr');

        // hide this row first
        row.hide();

        // next, get the next TR, see if it is a notes row, and hide it if it is
        var nxt = row.next();

        if (nxt.hasClass('show_notes')) {

            nxt.hide();

        }else
        {

            if (nxt.hasClass('odd')) {

                nxt.attr('class','even');

            }else
            {

                nxt.attr('class','odd');

            }

        }

        e.preventDefault();

    });
  • 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-20T08:10:04+00:00Added an answer on May 20, 2026 at 8:10 am

    Try doing this instead

    if (nxt.hasClass('show_notes')) {
        nxt.hide();
    }
    else {
        row.nextAll('tr').toggleClass('odd even');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the title doesn't make sense. Basically I have a series of strings
Sorry if the title doesn't make much sense, if you have a suggestion on
Sorry about the rubbish question title. I have a table SET_DEFINITIONS like this: SETKEY
Sorry for this title impossible to understand. I have this: <a class=directory> Directory 1
Sorry if that title doesn't make sense, I'm new to Rails and I'm building
Sorry, that title probably doesn't make much sense, but what I want to know
sorry if the title doesn't make much sense, I'll explain. I am learning Perl,
I'm sorry if the question's title doesn't really make sense but it's a problem
I'm sorry if this title doesn't describe the problem properly but I wasn't sure
Sorry about the title — wasn’t sure how to word it. Basically I have

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.