+ 3
Use a css class for all the displayed images, populate it with the same onclick event.
You only need one set of modal image container.
The modal would be updated with correct image and capture.
I simplified your code here with the same event function, but populate it to all image elements.
Practice DRY, don't repeat yourself on coding always would avoid unnecessary errors.
https://code.sololearn.com/WTb4eT16ooz2/?ref=app
0
There is no span with class="close", which causes the error.