Skip to content

Instantly share code, notes, and snippets.

@faridnsh
Created December 8, 2013 09:54
Show Gist options
  • Save faridnsh/7855369 to your computer and use it in GitHub Desktop.
Save faridnsh/7855369 to your computer and use it in GitHub Desktop.
Close popover when the body is clicked on, while using bootstrap popover.
var path = '#thePopoverContent',
element = $('#theButtonThatOpensThePopover')[0];
$(document).click(function (e) {
if (this !== element &&
e.target !== element &&
$('.popover').length &&
!$(e.target).parents(path).length) {
hide();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment