Remove DIV tag using Javascript or Jquery

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

Leave a Comment