Created
August 30, 2016 09:40
-
-
Save v1talii-dev/e2ac3c8f583b2f953b772b2c782fc611 to your computer and use it in GitHub Desktop.
javascript: hide element when clicked outside this element
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).on('click', function(e) { | |
if($(e.target).closest("#block").length) { | |
return; | |
} | |
if (!$(e.target).closest(".control").length) { | |
// hide element; | |
e.stopPropagation(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment