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

175
Visualizações
I can't seem to clear a tables tbody properly, not delete, just clear the rows and whatever cells are in it

This is how my html looks like

<table id="emails-list">
        <tbody>
            
        </tbody>
    </table>

Then using Javascript I want to add rows and columns but I first want to clear anything that is in the tbody so as to not append/stack the same rows and columns everytime the function is called.

function DisplayEmails(item){
  
  //searching for table
  var table = document.querySelector('tbody');

  // somehow clear the tbody of the table here ?????
  
  // adding a row
  var row = table.insertRow(0);
  // adding 3 cells to the row
  var cell1 = row.insertCell(0);
  var cell2 = row.insertCell(1);
  var cell3 = row.insertCell(2);

  cell1.innerHTML = item.sender;
  cell2.innerHTML = item.subject;
  cell3.innerHTML = item.timestamp;
about 4 years ago · Juan Pablo Isaza
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