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

136
Views
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 answers
Answer question

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 Report

0

this is jquery code )):

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

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 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!