nettsiden/www/js/galleri.js

18 lines
604 B
JavaScript
Raw Normal View History

2024-04-07 01:50:31 +02:00
const modal = document.getElementById('modal');
const modalImg = document.getElementById("modal-content");
const captionText = document.getElementById("modal-caption");
document.addEventListener('click', function (e) {
if (e.target.className.indexOf('modal-target') !== -1) {
2024-04-07 01:50:31 +02:00
// Open modal
const img = e.target;
modal.style.display = "block";
2024-04-07 01:50:31 +02:00
modalImg.src = img.dataset.fullsrc;
captionText.innerHTML = img.alt;
2022-01-25 15:04:00 +01:00
} else if (modal.style.display != "none") {
2024-04-07 01:50:31 +02:00
// Close modal
2022-01-25 15:04:00 +01:00
modal.style.display = "none";
2024-04-07 01:50:31 +02:00
modalImg.src = "";
}
});