var modal = document.querySelector('.modal'); // assuming you have only 1 var html = document.querySelector('html'); modal.querySelector('.modal-background').addEventListener('click', function(e) { e.preventDefault(); modal.classList.remove('is-active'); html.classList.remove('is-clipped'); }); modal.querySelector('.modal-close').addEventListener('click', function(e) { e.preventDefault(); modal.classList.remove('is-active'); html.classList.remove('is-clipped'); }); modal.querySelector('.modal-close-button').addEventListener('click', function(e) { e.preventDefault(); modal.classList.remove('is-active'); html.classList.remove('is-clipped'); });