I'm trying to dynamically create 100 li's and append a "template" of html inside of each one. On top of that, I want to dynamically increment the id="Increment" span element by 1 inside that template like... 1, 2, 3 ---> 100
Desired Effect: http://jsfiddle.net/LQp5y/
Current Work: http://jsfiddle.net/QyWS7/
HTML Markup:
<section class="main">
<div class="wrapper">
<ul id="currentStore" class="row">
<!-- HTML TEMPLATE -->
</ul>
</div>
</section>
HTML Template:
<!-- 100 li's -->
<li>
<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
<div class="flipper">
<div class="front">
<span>1</span>
</div>
<div class="back">
<span>Buy</span>
</div>
</div>
</div>
</li>
Javascript (currently)
var toAdd = document.createDocumentFragment();
for(var i=1; i < 101; i++){
var newLi = document.createElement('li');
newLi.id = 'Product'+i;
newLi.className = 'item';
newLi.innerHTML = 'Product '+i;
toAdd.appendChild(newLi);
}
document.getElementById('currentStore').appendChild(toAdd);
Can someone show me the proper way to do this? Thanks in advance!