so I know this question has been asked so many times but I still haven't found a solution to my problem:
HTML
<div class="thumbnails"></div>
JS
function createImg(index){
    tempImg.src = paths[index];
}
function appendImg(){
    var img = document.createElement('img');
    img.src = tempImg.src;
    createImg(index++);
    img.setAttribute('id', 'firsts');
    ** document.getElementsByClassName('thumbnails').appendChild(img); **
}
I want to append the newly created image/s to my div. I've tried many versions of doing it but nothing seemed to work.
If I use "document.body.appendChild(img);" this works just fine but it isn't what I need.
 
    