bootstrap 点击空白处popover弹出框隐藏实例
代码:
<div>
<a class="btn btn-success show" title="Popover title"
data-container="body" data-toggle="popover" data-placement="bottom"
data-content="底部的 Popover 中的一些内容"> aaaa </a>
</div>
<script>
$(function () {
initPopover();
})
function initPopover() {
$(".show").popover({
container: "body",
trigger: " manual" //手动触发
}).on('show.bs.popover', function () {
$(this).addClass("popover_open");
}).on('hide.bs.popover', function () {
$(this).removeClass("popover_open");
});
$(".show").click(function () {
if ($(this).hasClass("popover_open")) {
$(this).popover("hide")
} else {
$(".popover_open").popover("hide");
$(this).popover("show");
}
var e = arguments.callee.caller.arguments[0] || event;
e.stopPropagation();
});
$(document).click(function () {
$(".show").popover("hide");
});
}
</script>注意点:
1、不适用于button,a、img等可用
2、show.bs.popover:当调用show 实例方法时立即触发该事件。
shown.bs.popover:当弹出框对完全弹出时触发该事件(将等待 CSS 过渡效果完成)。
hide.bs.popover:当调用hide 实例方法时立即触发该事件。
hidden.bs.popover:当工具提示完全隐藏时触发该事件(将等待 CSS 过渡效果完成)。
3、引入jquery和bootstrap头文件
4、取消冒泡
相关推荐
jingtianyiyi 2016-04-30
zh000 2018-09-13
jingtianyiyi 2016-09-19
twtonrg 2016-04-30
zh000 2019-06-25
jingtianyiyi 2015-11-23
lixia 2017-05-10
DJPLH 2017-03-29
iChangebaobao 2017-02-27
hllinc 2017-02-27
niepxiya 2017-02-23
wuchangjian 2017-02-21
zh000 2019-05-09
twtonrg 2016-12-28
乔乔 2016-08-09
Chinahdy 2016-06-12
wuchangjian 2016-04-27
ivoryqin 2019-05-05
soulis 2016-04-03