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

14 lines
494 B
JavaScript
Raw Normal View History

2021-10-20 13:40:44 -07:00
const openButton = document.getElementById('trigger-modal');
2021-10-18 14:33:12 -07:00
const closeButton = document.getElementById('close-modal');
2022-01-12 12:38:29 -08:00
const backdrop = document.getElementById('backdrop')
2021-10-18 14:33:12 -07:00
2021-10-20 15:05:31 -07:00
function toggleModal() {
2021-10-18 14:33:12 -07:00
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-18 14:33:12 -07:00
}
2021-10-20 15:05:31 -07:00
openButton.addEventListener('click', toggleModal);
closeButton.addEventListener('click', toggleModal);