Created
April 28, 2019 07:47
-
-
Save AlexKardone/4b2d228101279412f3a6796fed3aa32f to your computer and use it in GitHub Desktop.
Close popup when click outside it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get the container of the popup window | |
var wind = setup.querySelector('.popup-window'); | |
var closePopup = function() { | |
setup.classList.add('hidden'); | |
}; | |
document.body.addEventListener('click', function(evt) { | |
if (!wind.contains(evt.target)) { | |
closePopup(); | |
} | |
}, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment