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

20 lines
675 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');
function openModal() {
2021-10-20 20:40:44 +00:00
const container = document.querySelector('.popup-container');
2021-10-18 21:33:12 +00:00
const modalDiv = document.querySelector('.popup-modal');
modalDiv.classList.add('show');
2021-10-20 20:40:44 +00:00
container.classList.add('show');
2021-10-18 21:33:12 +00:00
}
function closeModal() {
2021-10-20 20:40:44 +00:00
const container = document.querySelector('.popup-container.show');
2021-10-18 21:33:12 +00:00
const modalDiv = document.querySelector('.popup-modal.show');
modalDiv.classList.remove('show');
2021-10-20 20:40:44 +00:00
container.classList.remove('show');
2021-10-18 21:33:12 +00:00
}
openButton.addEventListener('click', openModal);
closeButton.addEventListener('click', closeModal);