代碼:
<div> <a class="btn btn-success show" title="Popover title" data-container="body" data-toggle="popover" data-placement="bottom" data-content="底部的 Popover 中的一些內(nèi)容"> aaaa </a></div><script> $(function () { initPopover(); }) function initPopover() { $(".show").popover({ container: "body", trigger: " manual" //手動(dòng)觸發(fā) }).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>注意點(diǎn):
1、不適用于button,a、img等可用
2、show.bs.popover:當(dāng)調(diào)用show 實(shí)例方法時(shí)立即觸發(fā)該事件。
shown.bs.popover:當(dāng)彈出框?qū)ν耆珡棾鰰r(shí)觸發(fā)該事件(將等待 CSS 過(guò)渡效果完成)。
hide.bs.popover:當(dāng)調(diào)用hide 實(shí)例方法時(shí)立即觸發(fā)該事件。
hidden.bs.popover:當(dāng)工具提示完全隱藏時(shí)觸發(fā)該事件(將等待 CSS 過(guò)渡效果完成)。
3、引入jquery和bootstrap頭文件
4、取消冒泡
以上這篇bootstrap 點(diǎn)擊空白處popover彈出框隱藏實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注