最近做个项目是用bootstrap搭建的网站,因为其自带弹出框很好使,便直接拿过来用了。
不废话直接进入正题
共分两步
1.
首先设弹出框方式为自动
popover(function(){
trigger:'manual',
})
2.
(1)然后调用两种方法,一种点击事件为 点击该元素 ,弹出该元素 弹出框
(2)第二种则是点击document也就是 点击任意地方 将该元素的弹出框隐藏
$("element").click(function(){
$(this).popover("show");
})
$("element").on("shown.bs.popover",function(){
var _this=this;
$(document).one("click",function(){
console.log(1);
$(_this).popover("hide");
});
})