I have a problem with JavaScript.
I need to delete a list of divs from the parent div.
So i tried this:
var divs = parent.getElementsByTagName("div");
if(divs != null)
{
for(var v = 0; v < divs.length; v++)
{
parent.removeChild(divs[v]);
}
}
But the problem is, that JS doesn’t remove all of the divs. JS only removes the half of the list.
I also tried this:
var divs = parent.getElementsByTagName("div");
if(divs != null)
{
for(var v = 0; v < divs.length; v++)
{
parent.removeChild(divs[0]);
}
}
But with the same results
Please help?
Two solutions:
1: count down
2: cache length: