var items = 10; var waitTime = 10; var maxItems = 1000; var itemCount = 0; setInterval(function(){ if(itemCount > maxItems) {return;} itemCount++; var _top = Math.floor((Math.random() * 90) + 1); var _left = Math.floor((Math.random() * 90) + 1); var thisDiv = document.createElement("DIV"); thisDiv.classList.add("item"); thisDiv.innerHTML = Math.floor((Math.random() * 1)+ 0.5); thisDiv.style.top = _top + '%'; thisDiv.style.left = _left+'%'; document.getElementById("container").appendChild(thisDiv); } , waitTime);