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

139
Visualizações
Remove DIV tag using Javascript or Jquery

How do I remove a DIV with a specific value?

<div value="0" class="task_row"></div>

I want to remove the above div which has value 0.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

As Ben Rowe points out in the comments, value is not a valid attribute of the div tag. And both the jQuery solution and the solution that uses getElementsByTagName() has to iterate through a list, which is bad for performance. I think that creating an id attribute instead is a better option:

<div id="task_row_0" class="task_row"></div>

And then you can just do:

var div = document.getElementById("task_row_" + taskId);
div.parentNode.removeChild(div);
over 4 years ago · Santiago Trujillo Relatório

0

this is jquery code )):

$('div').each(function(){
  if($(this).attr('value') == '0'){
    $(this).remove();
  }
});
over 4 years ago · Santiago Trujillo Relatório

0

var divs = document.getElementsByTagName('div');
for(var i = divs.length; i; i -= 1) {
    if (divs[i].getAttribute('value') == 0) {
        divs[i].parentNode.removeChild(divs[i]);
    }
}
over 4 years ago · Santiago Trujillo 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