document.addEventListener("DOMContentLoaded", function () {
// Get modal element and button
var modal = document.getElementById("imageModal");
var btn = document.getElementById("openModal");
var span = document.getElementsByClassName("close")[0];
// Open modal on button click
if (btn) {
btn.onclick = function () {
modal.style.display = "block";
};
}
// Close modal on "x" click
if (span) {
span.onclick = function () {
modal.style.display = "none";
};
}
// Close modal when clicking outside of the modal content
window.onclick = function (event) {
if (event.target === modal) {
modal.style.display = "none";
}
};
});