You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
808 B
26 lines
808 B
const imageGallery = document.getElementById("imageGallery");
|
|
const lightbox = document.getElementById("lightbox");
|
|
const lightboxImage = document.getElementById("lightboxImage");
|
|
const closeLightbox = document.querySelector(".close-lightbox")
|
|
|
|
|
|
imageGallery.addEventListener("click", (event) => {
|
|
console.log(event.target.tagName);
|
|
const target = event.target;
|
|
if (target.tagName === "IMG") {
|
|
const fullImage = target.getAttribute("data-full");
|
|
lightbox.style.display = "block";
|
|
lightboxImage.src = fullImage;
|
|
console.log(fullImage);
|
|
}
|
|
})
|
|
|
|
closeLightbox.addEventListener("click", () => {
|
|
lightbox.style.display = "none";
|
|
})
|
|
|
|
window.addEventListener("click", event => {
|
|
if (event.target === lightbox) {
|
|
lightbox.style.display = "none";
|
|
}
|
|
})
|