-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (29 loc) · 1.13 KB
/
script.js
File metadata and controls
35 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Wait until page fully loads
document.addEventListener("DOMContentLoaded", function () {
const modal = document.getElementById("certModal");
const modalImg = document.getElementById("modalImage");
const closeBtn = document.querySelector(".close-btn");
const overlay = document.querySelector(".modal-overlay");
const certCards = document.querySelectorAll(".cert-card");
// ================= OPEN MODAL =================
certCards.forEach(card => {
card.addEventListener("click", function () {
const img = this.querySelector("img");
modalImg.src = img.src;
modal.classList.add("active");
document.body.style.overflow = "hidden";
});
});
// ================= CLOSE MODAL =================
function closeModal() {
modal.classList.remove("active");
document.body.style.overflow = "auto";
}
closeBtn.addEventListener("click", closeModal);
overlay.addEventListener("click", closeModal);
document.addEventListener("keydown", function (e) {
if (e.key === "Escape") {
closeModal();
}
});
});