-
Notifications
You must be signed in to change notification settings - Fork 3
/
modal.js
28 lines (23 loc) · 911 Bytes
/
modal.js
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
const showModalBtn = document.querySelector(".show-modal");
const modal = document.querySelector(".modal");
const backDrop = document.querySelector(".backdrop");
const closeModalBtn = document.querySelector(".close-modal");
const confirmModalBtn = document.querySelector(".confirm-modal");
showModalBtn.addEventListener("click", ()=>{
modal.style.opacity = "1";
modal.style.transform = "translateY(20vh)";
backDrop.style.display = "block";
});
function closeModal(){
modal.style.opacity = "0";
modal.style.transform = "translateY(-100vh)";
backDrop.style.display = "none";
}
closeModalBtn.addEventListener("click", closeModal);
confirmModalBtn.addEventListener("click", ()=>{
modal.style.opacity = "0";
modal.style.transform = "translateY(-100vh)";
backDrop.style.display = "none";
window.alert("Confirm Clicked!")
});
backDrop.addEventListener("click", closeModal);