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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:42:07+00:00 2026-06-16T16:42:07+00:00

I have several tables on the same page. I am attempting to write jQuery

  • 0

I have several tables on the same page. I am attempting to write jQuery code that would individually count the rows to each of my tables on the page, and depending whether the # of rows are even or odd, apply different CSS to each individual table.

Using jQuery’s .each function, I am able to select each table. But I need a way to count the number of rows in that individual table using the “this” keyword. If there was just one table I could use

var amountOfRows = $(".data  tbody  tr").length;

But since there are multiple tables I need some code that incorporates the “this” keyword to individually get each row length.

So I am really just wanting to know how to use the “this” keyword to be able to read the # of rows of each of my tables on my page.

Here is a basic jsfiddle: http://jsfiddle.net/49jNn/1/

Here is a simplified version of my HTML code, I have 2-4 a page.

<table class="data">
    <thead>
        //head row
    </thead>
    <tfoot>
        //footer row
    </tfoot>

    //I want the number of these rows
    <tr>
        //multiple <td>
    </tr>
    <tr>
        //multiple <td>
    </tr>
    <tr>
        //multiple <td>
    </tr>
</table>

My jQuery code so far, able to loop through the # of tables on a page.

$('table').each(function() {
    alert("table");
});
  • 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-16T16:42:08+00:00Added an answer on June 16, 2026 at 4:42 pm

    You can use $(selector, context);

    $('tbody tr', this).length;
    

    or find method:

    $(this).find('tbody tr').length;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with several tables on it with the same class name.
I have a page with several drop down lists that all have the same
I have several sections of code that insert values into different tables in my
I have several tables that I am selecting data from. I am trying to
I have several tables that I want to put side by side, however when
I have several database tables that just contain a single column and very few
I have a function that updates several tables. As an example, let's say it
I have several different tables, but they all have 2 columns that are the
I'm using rails 3. In my database I have several tables that work together
In my DB schema I have several tables that will be related to a

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.