Skip to content
Advertisement

API image popup finding the correct src path

I have an API image gallery using Unsplash [https://codepen.io/aaron_1986/pen/WNybEmZ]; when I click to enlarge an image – the path of the src is missing. Moreover, I cannot understand how to enter the correct src path to enlarge the image.

JavaScript
JavaScript

Advertisement

Answer

So basically your issue is the following:

Whenever you click on an image in order to enlarge it, you toggle the active class on your div.popup element which makes visible.

JavaScript

However you never set the src of the img element inside your popup.

You could try adding an id to the img tag inside your popup and setting the image src dynamically.

JavaScript
JavaScript

Link to codepen: https://codepen.io/lo1c/pen/bGKNmGr

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement