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

The Archive Base Latest Questions

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

table.rows.length in Java script returns the count of rows in the table including rows

  • 0

table.rows.length in Java script returns the count of rows in the table including rows in <thead> tag. What I need is, if there is a header row (inside <thead> ) with only <th> elements, I want to neglet that row and I need only the count of rows having data in it not the header elements.

Note : I can not use table.rows.length - 1 as I can not modify Javascript. I can only modifiy in HTML side. Here is the code sample snippet. Here I need count as 4 not 5.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sample</title>
<script type="text/javascript">
function call(){    
    alert(document.getElementById('tab').rows.length);
}
</script>
</head>
<body onload="call()">
<table id="tab" border="1">
    <thead>
        <th>
          header 1
         </th>
         <th>
            header 2
         </th>           
    </thead>
    <tbody>
        <tr>
             <td> data1</td>
             <td> data1</td>
        </tr>
        <tr>
             <td> data2</td>
             <td> data2</td>
        </tr>
        <tr>
             <td> data3</td>
             <td> data3</td>
        </tr>
        <tr>
             <td> data</td>
             <td> data4</td>
        </tr>
    </tbody>    
  </table>  
 </body>
</html>
  • 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-16T17:34:08+00:00Added an answer on June 16, 2026 at 5:34 pm

    Reassign id to the <tbody> element:

    <table border="1">
        <tbody id="tab">
        ...
    

    As this element is <HTMLTableSectionElement> one, it has rows (HTMLCollection) property too, so you won’t have to make any changes in your JS at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how remove html table rows after 2nd row? if in table have 5 row,
I am displaying table rows in the form. Each row has 5 columns, one
Initial javascript to get a string/array: <script type=text/javascript> $(document).ready(function() { $(#table).tableDnD({ onDrop: function(table, row){
I have a table I need to get the number of rows on. I'm
I have a table in which i append rows on onclick event, the row
I wrote a JS script to dynamically add rows on a table. On a
What is the difference between cuke4duke.Table.rows() and cuke4duke.Table.raw() ? I've found that when I'm
I am trying to delete MySQL table rows from a Web page using Perl.
Using PHP I echo out table rows in a loop like this: <?php /*
I have created mysql to delete table rows, which have lower DATETIME value than

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.