I am referring to this tutorial about modal image here.
The example show ONE image, which when clicked on, pops up in a modal. Some JavaScript is involved and I am not quite familiar with JavaScript.
If instead of this line:
<img id="myImg" src="img_snow.jpg" alt="Snow" style="width:100%;max-width:300px">
,I have multiple images (say 4) arranging like below:
<img id="myImg1" src="img_snow.jpg" alt="Snow" style="width:100%;max-width:300px">
<img id="myImg2" src="img_snow.jpg" alt="Snow" style="width:100%;max-width:300px">
<img id="myImg3" src="img_snow.jpg" alt="Snow" style="width:100%;max-width:300px">
<img id="myImg4" src="img_snow.jpg" alt="Snow" style="width:100%;max-width:300px">
how do I modify this code (and maybe the JavaScript) so that the modal popup shows the respective image that is clicked on?
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
Creating one modal for each image seems like a very crude way to do this.
Thanks,