You could just simply do :
function imgPostLoad(totalpics, placeholder) {
for (var i = 0; i < totalpics; i++) {
var picture = document.getElementsByClassName(placeholder)[i];
picture.src = "/img/" + picture.getAttribute("id") + ".jpg";
}
}
What the problem is in your code is that by the time img
was loaded picture
is another variable.