当前位置: 移动技术网 > IT编程>开发语言>JavaScript > bootstrap 点击空白处popover弹出框隐藏实例

bootstrap 点击空白处popover弹出框隐藏实例

2018年01月30日  | 移动技术网IT编程  | 我要评论

代码:

<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、取消冒泡

以上这篇bootstrap 点击空白处popover弹出框隐藏实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网