odin-default-css-exercises/animation/02-pop-up/script.js

14 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);