From 09cc986a8a28445c189b4452aa93a27e919ba01a Mon Sep 17 00:00:00 2001 From: inesder Date: Tue, 13 Feb 2024 11:13:18 +0100 Subject: [PATCH] close modal by clicking on X, fixes #1 --- starterOnly/modal.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/starterOnly/modal.js b/starterOnly/modal.js index 694a848564..bbec6ed428 100644 --- a/starterOnly/modal.js +++ b/starterOnly/modal.js @@ -11,6 +11,7 @@ function editNav() { const modalbg = document.querySelector(".bground"); const modalBtn = document.querySelectorAll(".modal-btn"); const formData = document.querySelectorAll(".formData"); +const closeBtn = document.querySelector(".close"); // launch modal event modalBtn.forEach((btn) => btn.addEventListener("click", launchModal)); @@ -20,4 +21,8 @@ function launchModal() { modalbg.style.display = "block"; } +// closing modal event +closeBtn.addEventListener("click", function(){ + modalbg.style.display = "none" +});