//给body追加监听
$('body').on('click', function (event) {
var target = $(event.target);
if (target.attr("id") !== "customer-reviews") {
$('#customer-reviews').popover('hide');
}
});
//前台代码
<div class="comment_popover"><!--popover弹出caret-->
<a class="text-muted cursor">
<i class="fa fa-caret-down " id="customer-reviews" data-container="body" data-toggle="popover"
data-placement="bottom" data-html="true" data-content='<div class="row " style="width:600px" id="popover-div">
<div class="col-md-4">........'>
</i>
</a>
<span>n customer reviews</span>
</div>
因为bootstrap的popover组件没有点击非控件区使popover消失机制,需要人为添加,也可用modal代替,因为此控件具有内置这个功能。