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

13 lines
452 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');
2021-10-20 22:05:31 +00:00
function toggleModal() {
const container = document.querySelector('.button-container');
2021-10-18 21:33:12 +00:00
const modalDiv = document.querySelector('.popup-modal');
2021-10-20 22:05:31 +00:00
modalDiv.classList.toggle('show');
container.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);