Stumped and I am sure there is an easy explanation to this.
So I want to iterate through all of the class names called 'images' and hide say the last 4:
images = document.getElementsByClassName("images");
for (var i = 0; i < images.length; i++) {
if(images[i] == images[5] || images[6] || images[7] || images[8]) {
images[5].style.display = "none";
images[6].style.display = "none";
images[7].style.display = "none";
images[8].style.display = "none";
}
}
Is there anyway of making this code shorter? Seems a bit laborious if you were to have loads of images.
No frameworks on this please! Many thanks for your help.