Possible Duplicate:
use remove() on multiple elements
I am trying to remove all elements that have a tag name of “label”. I have the following code. It works to some degree, but it only removes 1 label. The other 5 still remain. How can I change the code to remove all “label” tags?
element = document.getElementsByTagName("label");
for (index = 0; index < element.length; index++) {
element[index].parentNode.removeChild(element[index]);
}
1 Answer