Skip to content

Instantly share code, notes, and snippets.

@handleman
Forked from thisgeek/gist:399081
Last active August 29, 2015 14:10
Show Gist options
  • Save handleman/3e81400f21bc24ccd370 to your computer and use it in GitHub Desktop.
Save handleman/3e81400f21bc24ccd370 to your computer and use it in GitHub Desktop.
hide element when user clicks outside the element
$.fn.hideOnClickOutside = function () {
target = $(this);
$(document).on('click', function() {
target.hide();
});
target.click( function(event) {
event.stopPropagation();
});
return target;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment