I want to remove the ChildNodes of a DIV with a specific className.
What will be the best possible way?
Thanks.
I want to remove the ChildNodes of a DIV with a specific className.
What will be the best possible way?
Thanks.
var myDiv = document.getElementById('my-div'),
children = myDiv.childNodes,
len = children.length,
reg = /(?:\s|^)fooClass(?:\s|$)/;
while (len--) {
if (reg.test(children[len].className || '')) {
myDiv.removeChild(children[len]);
}
}