odin-css-exercises/animation/02-pop-up/script.js
2022-01-12 14:38:29 -06:00

13 lines
494 B
JavaScript

const openButton = document.getElementById('trigger-modal');
const closeButton = document.getElementById('close-modal');
const backdrop = document.getElementById('backdrop')
function toggleModal() {
const modalDiv = document.querySelector('.popup-modal');
const backdrop = document.querySelector('.backdrop')
modalDiv.classList.toggle('show');
backdrop.classList.toggle('show');
}
openButton.addEventListener('click', toggleModal);
closeButton.addEventListener('click', toggleModal);