I just want a for loop to print the same image 10 times without manually creating 10 's since I may want to append more later. I have used this exact same code in other projects and it has worked but for some reason it won't work this time.
The image html is:
<img id = "crate" src="img/Acrate.png"/>
Here's my code:
function drawCrates (){
for(i = 0; i < 10; i++){
var crate_img = document.createElement("IMG");
crate_img.setAttribute("src", "images/Acrate.png");
document.getElementById("crate").appendChild(crate_img);
}
}
drawCrates();
#crateelement to a div and this will work