Stack Overflow на русском Asked by user389240 on January 10, 2021
Как можно сделать функцию с названием closeAllPopups что бы задействовала данный код ?
window.addEventListener("keydown", function(e) {
if (e.keyCode == 27 && editPopup.classList.contains('popup_active')) {
editPopup.classList.remove('popup_active');
}
if (e.keyCode == 27 && addPopup.classList.contains('popup_active')) {
addPopup.classList.remove('popup_active');
}
if (e.keyCode == 27 && imagePopup.classList.contains('popup_active')) {
imagePopup.classList.remove('popup_active');
}
}, true);
function closeAllPopups() {
document.querySelectorAll('.popup_active').forEach(i => i.classList.remove('popup_active'));
}
window.addEventListener("keydown", function(e) {
if (e.keyCode == 27)
closeAllPopups();
}, true);
Correct answer by Igor on January 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP