Where is the problem in the following code?
Consider now this alert statement:Code:totalElementArray = document.getElementsByTagName("li"); j = 0; for (i = 0; i < totalElementArray.length; i = i + 1) { if (totalElementArray[i].getAttribute("id").substr(0, 6) == "liBook") { elementArray[j] = totalElementArray[i]; j = j + 1; } }
If I put this alert statement after "elementArray[j] = totalElementArray[i];" in the if-statement, it prints out exactly what it should print out.Code:alert (elementArray[j].getAttribute("id").substr(0));
However, if I run this for loop:
AFTER the end of the previous for loop, NOTHING prints out. What happened to all the items in elementArray?Code:for (i = 0; i < elementArray.length; i = i + 1) alert (elementArray[i].getAttribute("id").substr(0));
Thanks so much.
Ken



Reply With Quote





Bookmarks