HTML
<div id="this1"></div>
JS
var total = 5;
for (var i=0; i<total; i++){
var id = "this" + i.toString();
var s= document.getElementById("this1");
s.innerHTML += id;
s.innerHTML += "<br/>";
}
Output
this0
this1
this2
this3
this4
What I'd like is to change the element selector to the var id.
var s= document.getElementById(id);
When I do this the loop iterates once and stops. If I change the for loops i to 1,2,3,etc and match the html div id with that IE:
html
<div id="this3"></div>
js
for (var i=3; i<total; i++){
output
this3
I get one successful output, as I should. However, starting the iterator at 0 I get 1 loop and that's it.
Is there something fundamental I'm not noticing in my half awakeness?