Let's consider the following code
var ULs = document.getElementsByTagName('ul');
for(var i = 0; i < ULs.length; i++) {
var ulLIs = ULs[i].getElementsByTagName('li');
for(var n = 0; n < ulLIs.length; n++) {
ulLIs[n].parentNode.removeChild(ulLIs[n]);
}
}
<ul>
<li>1-1</li>
<li>1-2</li>
<li>1-3</li>
<li>1-4</li>
</ul>
<ul>
<li>2-1</li>
<li>2-2</li>
<li>2-3</li>
<li>2-4</li>
</ul>
As you see, JavaScript removes only even or odd childs. But I need remove all the childs.
How can I do it?