Sanjai Palliyil Sanjai Palliyil - 15 days ago 5
HTML Question

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.


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);