i am trying to create a simple photo gallery where one photo is big and there are also thumbinals at the bottom which when clicked become that big photo. Galleries are in separate modal windows. My code only works in the first modal window. In fact this is my very first time using jquery. I can't even find how to use the console.log to check where the problem is.
HTML:
<div class="modal_content">
<div class="gallery">
<img id="big" src="foto/20210322_100211.jpg">
<div id="thumbnails">
<a href="foto/20210218_135910.jpg"><img src="foto/resized/20210218_135910 small.jpg"></a>
<a href="foto/20210322_100211.jpg"><img src="foto/resized/20210322_100211 small.jpg"></a>
<a href="foto/20210322_153418.jpg"><img src="foto/resized/20210322_153418 small.jpg"></a>
</div>
</div>
<!--other content-->
</div>
<div class="modal_content">
<div class="gallery">
<img id="big" src="foto/20210322_153418.jpg">
<div id="thumbnails">
<a href="foto/20210218_135910.jpg"><img src="foto/resized/20210218_135910 small.jpg"></a>
<a href="foto/20210322_100211.jpg"><img src="foto/resized/20210322_100211 small.jpg"></a>
<a href="foto/20210322_153418.jpg"><img src="foto/resized/20210322_153418 small.jpg"></a>
</div>
</div>
<!--other content-->
</div>
jQuery:
$("#thumbnails a").on("click", function (e) {
e.preventDefault();
$("#big").attr("src", $(this).attr("href"));
});