Advertisement
Virajsinh

Bootstrap Popover Outside Click to Close

Dec 5th, 2024 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.43 KB | Source Code | 0 0
  1. //Bootstrap popover, hide on click outside
  2. // add this on => data-trigger="focus"
  3.  
  4. $('body').on('click', function (e) {
  5.     $('[data-toggle=popover]').each(function () {
  6.         // hide any open popovers when the anywhere else in the body is clicked
  7.         if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
  8.             $(this).popover('hide');
  9.         }
  10.     });
  11. });
  12.  
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement