You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
478 B
JavaScript

var modal = document.querySelector('[data-modal]');
modal.addEventListener('click', function (event) {
event.preventDefault();
var modalId = document.getElementById(modal.dataset.modal);
modalId.classList.add('open');
var exits = modalId.querySelectorAll('.modal-exit');
console.log(exits)
exits.forEach(function (exit) {
exit.addEventListener('click', function (event) {
event.preventDefault();
modalId.classList.remove('open');
});
});
});