Skip to content

Instantly share code, notes, and snippets.

@TemporaryJam
Created July 21, 2015 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TemporaryJam/2f9589dd83abe9cd5e64 to your computer and use it in GitHub Desktop.
Save TemporaryJam/2f9589dd83abe9cd5e64 to your computer and use it in GitHub Desktop.
Detect a click outside of an element
$(document).click(function(event) {
if(!$(event.target).closest('#id-of-thing-youre-detecting-the-click-outside-of').length) {
//close something or do something
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment