Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda