Solution: How to close Twitter #Bootstrap popover with a click anywhere on the page using #jQuery

Updated September 2, 2015 ‚óŹ 1,553 views

If you are manually triggering a popover using the Boots strap class, chances are you want to close the popover too when user clicks anywhere else on the page.

Use the example code below to achive this goal. That highlighted part of the code closes the popover when a user clicks anywhere on the body of a page.

jQuery(function($) {
        $(".pop-user-info").not(this).popover("hide"); //hide other popovers
        return false;
        $(".pop-user-info").popover("hide"); //hide all popovers when clicked on body



Our Terms of Use and Privacy Policy have changed.
By continuing to use this site, you are agreeing to the new Privacy Policy and Terms of Service.