I don't really know what the problem is here. I am trying to view the small pics as big pics when I click on them. I have succeeded, however, an error message is appearing in the inspector-window that says: "Cannot set property 'onclick' of undefined"
here is the code to make the small images big.
var Bigimg = document.getElementById("BigImg");
var smallimg = document.getElementsByClassName("small-img"); // this is an array
smallimg[0].onclick=function() {
Bigimg.src = smallimg[0].src;
}
smallimg[1].onclick=function() {
Bigimg.src = smallimg[1].src;
}
smallimg[2].onclick=function() {
Bigimg.src = smallimg[2].src;
}
smallimg[3].onclick=function() {
Bigimg.src = smallimg[3].src;
}
again it's working as it should, however, I am trying to move on to the next step where I am trying to get my shop-cart to function, but I am trying to test my code with the help of Console.log(the button I am pressing) and it's not working.
Aucun commentaire:
Enregistrer un commentaire