my goal is to change id="current"
image source with source of a clicked image. The current image should display image source of higher resolution image and lower resolution images should be there as an option to choose from. When lower resolution image is clicked current image should display a particular image with higher resolution, remaining images have lower res.
photos/thumbnails/...
= lower res images
photos/....
= higher res images.
current
is static and displays clicked connect with higher res other in lower res.
Thank you very much I´m hopeless right now. Thank you for your advice and guidance, it´s my first js project.
<div class="container">
<div class="main-img">
<img src="photos/thumbnails/01.jpg" id="current">
</div>
<div class="imgs">
<img src="photos/thumbnails/01.jpg" id="1">
<img src="photos/thumbnails/02.jpg" id="2">
<img src="photos/thumbnails/03.jpg" id="3">
<img src="photos/thumbnails/04.jpg" id="4">
<img src="photos/thumbnails/05.jpg" id="5">
<img src="photos/thumbnails/06.jpg" id="6">
<img src="photos/thumbnails/07.jpg" id="7">
<img src="photos/thumbnails/08.jpg" id="8">
<img src="photos/thumbnails/09.jpg" id="9">
<img src="photos/thumbnails/10.jpg" id="10">
<img src="photos/thumbnails/11.jpg" id="11">
<img src="photos/thumbnails/12.jpg" id="12">
</div>
</div>
imgs.forEach(img => img.addEventListener("click", imgClick));
function imgClick(e) {
if(current.src .includes("thumbnails/") === true) {
for(let i = 1; i <= current.src.length; i += 1) {
i = [
[document.getElementById("1").src= "photos/01.jpg"],
[document.getElementById("2").src = "photos/02.jpg"],
[document.getElementById("3").src = "photos/03.jpg"],
[document.getElementById("4").src = "photos/04.jpg"],
[document.getElementById("5").src = "photos/05.jpg"],
[document.getElementById("6").src = "photos/06.jpg"],
[document.getElementById("7").src = "photos/07.jpg"],
[document.getElementById("8").src = "photos/08.jpg"],
[document.getElementById("9").src = "photos/09.jpg"],
[document.getElementById("10").src = "photos/10.jpg"],
[document.getElementById("11").src = "photos/11.jpg"],
[document.getElementById("12").src = "photos/12.jpg"]
]
}
}
// works
current.src = e.target.src;
}