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

14 lines
494 B
JavaScript
Raw Normal View History

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