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

14 lines
494 B
JavaScript
Raw Normal View History

2021-10-20 15:05:31 -07:00
const openButton = document.getElementById('trigger-modal');
const closeButton = document.getElementById('close-modal');
2022-01-12 12:38:29 -08:00
const backdrop = document.getElementById('backdrop')
2021-10-20 15:05:31 -07:00
function toggleModal() {
const modalDiv = document.querySelector('.popup-modal');
2022-01-12 12:38:29 -08:00
const backdrop = document.querySelector('.backdrop')
2021-10-20 15:05:31 -07:00
modalDiv.classList.toggle('show');
2022-01-12 12:38:29 -08:00
backdrop.classList.toggle('show');
2021-10-20 15:05:31 -07:00
}
openButton.addEventListener('click', toggleModal);
closeButton.addEventListener('click', toggleModal);