I am trying to make my site responsive to handheld actions. I have four images, all with the class="grid-photos". I am trying to make the photos expand when clicked, and close when clicked again.
<div class="grid-container">
<img class="grid-photos">
<img class="grid-photos">
<img class="grid-photos">
<img class="grid-photos">
As of now I can get it to work only with the first image using this Javascript
const gridPhotos = document.querySelector(".grid-photos");
document.querySelectorAll(".grid-photos").forEach((item) => {
item.addEventListener("click", (event) => {
gridPhotos.classList.toggle("expander");
});
});
I have tried querySelectorAll with [i] but to no avail.
Thank you for any help