So I have this code here:

What I'm trying to do is when I click on a thumbnail, the below larger image of it should display according to which thumbnail is clicked. I tried switching the larger image's src to that of the thumbnail src's value when clicked but it's not working correctly.

(I had to exectuce the js's function by calling itself instead of using onclick since the onclick doesn't seem to work when I tried wrapping it into the img tag).

Any help would be appreciated.

Oh wow, I just found a solution 5 minutes after posting:p
Here's the updated code:

My question now is, let's say I only have the thumbnails displayed on the page, when I click on a thumbnail a modal window should pop up showing all the thumbnails and the enlarged version of each thumbnail when clicked. How should I do this?