I have found the answer on how to do the same thing with jQuery How to show/hide big image by clicking on thumbnails?, but I would like to know how to do the same thing with just Javascript.
In jQuery there you can use $(this) to specify that the image that you clicked on should become the bigger image, but is there an equivalent without jQuery?
HTML
<ol>
<li class="thumbs">
<img src="images/thumbnails/t__01.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__02.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__03.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__04.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__05.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__06.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__07.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__08.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__09.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__10.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__11.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__12.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__13.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__14.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__15.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__16.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__17.jpg" alt="">
</li>
<li class="thumbs">
<img src="images/thumbnails/t__18.jpg" alt="">
</li>
</ol>
<div id="gallery"><img src="images/thumbnails/t__01.jpg" alt="">
</div>
I was thinking that I could link the li images to a image id using only CSS, but that would mean that if I pressed back, then it would go back to the previous image instead of the previous page.
One way of doing it may be to use on each image. The changeImage() would then change the current larger image to the one clicked. If the thumb clicked in the active image, then nothing happens. Else change the #gallery img src to the clicked thumbs' src.
I don't know how to convert that into code though. Thanks
this
. Please add more details like your markup and code you already tried, then we can give you more specific advice. – bfavaretto