假设任何时候都只能看到一个弹出窗口,则可以使用一组标志来标记何时有可见的弹出窗口,然后再隐藏它们。
如果在文档正文上设置了事件监听器,则在单击标有“ popup-marker”的元素时将触发该事件监听器。因此,您必须调用stopPropagation()事件对象。并在弹出窗口本身上单击时应用相同的技巧。
以下是执行此操作的JavaScript代码。它使用jQuery> = 1.7
jQuery(function() {
    var isVisible = false;
    var hideAllPopovers = function() {
       $('.popup-marker').each(function() {
            $(this).popover('hide');
        });  
    };
    $('.popup-marker').popover({
        html: true,
        trigger: 'manual'
    }).on('click', function(e) {
        // if any other popovers are visible, hide them
        if(isVisible) {
            hideAllPopovers();
        }
        $(this).popover('show');
        // handle clicking on the popover itself
        $('.popover').off('click').on('click', function(e) {
            e.stopPropagation(); // prevent event for bubbling up => will not get caught with document.onclick
        });
        isVisible = true;
        e.stopPropagation();
    });
    $(document).on('click', function(e) {
        hideAllPopovers();
        isVisible = false;
    });
});
http://jsfiddle.net/AFffL/539/
唯一的警告是您将无法同时打开两个弹出窗口。但是我认为这反而会使用户感到困惑:-)