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"; + } +}