var displayedImage = document.querySelector('.displayed-img');
var thumbBar = document.querySelector('.thumb-bar');
btn = document.querySelector('button');
var overlay = document.querySelector('.overlay');
/* Looping through images */
for(var i=1;i<=5;i++){
var newImage = document.createElement('img');
newImage.setAttribute('src', "images/pic"+i+".jpg");
thumbBar.appendChild(newImage);
}
function getPath(){
var path = this.document.getAttribute('src').value;
}
newImage.onclick=function(){
var path = newImage.getAttribute('src');
console.log(path);
displayedImage.setAttribute('src', path);
}
i tried printing out the path when i click on the image, but it only return the last value of newImage..but i have 4 pictures that can be selected