Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda