Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
I can't see the number of rows in the table correctly

I'm having a problem in correctly displaying the number of rows in the table.

In particular, rowCount is always equal to 1.

Can anyone kindly help me?

let table = document.getElementById("my-table");
allart.Items.forEach(function (item) {
let child = document.createElement("tr");
child.innerHTML = `
<td>${item.id}</td>
<td>${item.title}</a></td>
<td>${item.brand}</td>
table.appendChild(child);
}

var table = document.getElementById(my-table).tBodies[0];
var rowCount = table.rows.length;
<table id = "my-table" width = "90%">
         <tr>
             <th> Id </th>
             <th> Title </th>
             <th> Brand </th>
         </tr>

 </table>

Regarding the javascript code, I only put the code of interest because the whole code is too long

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

EDITED: tBodies will give you how many tbody tags () you are having in your HTML and it is not related to how many rows. As the reference: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table3

If you want to see how many rows you have in your table you can use this code:

var x = document.getElementById("my-table").rows.length;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!