Skip to content

Commit

Permalink
add modal close functionality OpenClassrooms-Student-Center#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingirorhaun committed Apr 21, 2024
1 parent 7e1ac69 commit fc13f5b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ function editNav() {

// DOM Elements
const modalbg = document.querySelector(".bground");
const modalBtn = document.querySelectorAll(".modal-btn");
const modalShowBtn = document.querySelectorAll(".modal-btn");
const formData = document.querySelectorAll(".formData");
const modalHideBtn = document.getElementsByClassName("close")[0];

// launch modal event
modalBtn.forEach((btn) => btn.addEventListener("click", launchModal));
// launch modal events
modalShowBtn.forEach((btn) => btn.addEventListener("click", launchModal));
modalHideBtn?.addEventListener("click", hideModal);

// launch modal form
function launchModal() {
modalbg.style.display = "block";
}


//hides the modal
function hideModal() {
modalbg.style.display = "none";
}

0 comments on commit fc13f5b

Please sign in to comment.