Simple photo gallery

Simple photo gallery
0

#1

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){

modal.style.display = "block";
modalfoto.src = this.src;
capfotoText.innerHTML = this.alt;
capfotoText.innerHTML = this.nextElementSibling.innerHTML;

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

#2

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 https://freecodecamp.org.

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: