Last active
April 6, 2020 18:55
-
-
Save IgorGavrilenko/911275f936cdaef4e4b84bfa3d17f6c3 to your computer and use it in GitHub Desktop.
закрыть блок по клику вне его
This file contains 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
$(document).mouseup(function (e){ // событие клика по веб-документу | |
var div = $("#popup"); // тут указываем ID элемента | |
if (!div.is(e.target) // если клик был не по нашему блоку | |
&& div.has(e.target).length === 0) { // и не по его дочерним элементам | |
div.hide(); // скрываем его | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment