From eba95ccc440db0f7541705f1ec1adf431088a303 Mon Sep 17 00:00:00 2001 From: Guillaume Payet Date: Mon, 26 Apr 2021 11:29:36 +0400 Subject: [PATCH] Fixed #1 --- starterOnly/modal.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/starterOnly/modal.js b/starterOnly/modal.js index 694a848564..fd861c28c9 100644 --- a/starterOnly/modal.js +++ b/starterOnly/modal.js @@ -11,6 +11,8 @@ function editNav() { const modalbg = document.querySelector(".bground"); const modalBtn = document.querySelectorAll(".modal-btn"); const formData = document.querySelectorAll(".formData"); +const closeModal = document.getElementsByClassName("close")[0]; + // launch modal event modalBtn.forEach((btn) => btn.addEventListener("click", launchModal)); @@ -20,4 +22,13 @@ function launchModal() { modalbg.style.display = "block"; } +// close modal form +closeModal.onclick = function() { + modalbg.style.display = "none"; +} +window.onclick = function(event) { + if (event.target == modalbg) { + modalbg.style.display = "none"; + } +}