I redo the modal window. There is one button with one class and 4 buttons with another class that open the same modal window and add themselves a new class. Opening a modal window and assigning a class is normal. But when I try to close the modal, the modal is closed, but the class is not deleted. There is a conflict between these lines.if (target.className == 'popup-close') { target.classList.remove('more-splash');
How can I, when I click on the close button, find the button with the assigned class and delete it.
let overlay = document.querySelector('.overlay'), close = document.querySelector('.popup-close'); document.addEventListener('click', function(event) { let target = event.target; if (target.className == 'description-btn' || target.className == 'more') { target.classList.add('more-splash'); overlay.style.display = "block"; document.body.style.overflow = 'hidden'; } if (target.className == 'popup-close') { target.classList.remove('more-splash'); overlay.style.display = "none"; document.body.style.overflow = ''; } });