Simple photo gallery

Simple photo gallery


I’m a beginner . what to add to working with multiple photos. not just 1? (javascript)
Code for modal photos. does not display more than one photo and I do not know how to add “for”. :frowning:

var modal = document.getElementById('Modalfoto');
var img = document.getElementById('modalfoto');
var modalfoto = document.getElementById("img01");
var capfotoText = document.getElementById("capfoto");

img.onclick = function(img){ = "block";
modalfoto.src = this.src;
capfotoText.innerHTML = this.alt;
capfotoText.innerHTML = this.nextElementSibling.innerHTML;

var span = document.getElementsByClassName("closefoto")[0];
span.onclick = function() { = "none";


Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

Happy coding :slight_smile: