當(dāng)用bootstrap時(shí),經(jīng)常需要在某個(gè)地方添加幫助按鈕,點(diǎn)擊或者鼠標(biāo)懸浮時(shí),提示幫助信息,然而,bt給我們提供的方法里貌似沒有,如果有哪位大神知道bootstrap有的可以留言,小弟學(xué)習(xí)了:代碼如下
之前的按鈕必須定義class為pop;
$(function(){ $(".pop").popover({placement:'right', trigger:'manual', delay: {show: 10, hide: 10}, html: true, title: function () { return $("#data-original-title").html(); }, content: function () { return $("#data-content").html(); // 把content變成html }}); $('body').click(function (event) { var target = $(event.target); // 判斷自己當(dāng)前點(diǎn)擊的內(nèi)容 if (!target.hasClass('popover') && !target.hasClass('pop') && !target.hasClass('popover-content') && !target.hasClass('popover-title') && !target.hasClass('arrow')) { $('.pop').popover('hide'); // 當(dāng)點(diǎn)擊body的非彈出框相關(guān)的內(nèi)容的時(shí)候,關(guān)閉所有popover } }); $(".pop").click(function (event) { $('.pop').popover('hide'); // 當(dāng)點(diǎn)擊一個(gè)按鈕的時(shí)候把其他的所有內(nèi)容先關(guān)閉。 $(this).popover('toggle'); // 然后只把自己打開。 }); });--------代碼非原創(chuàng),借鑒網(wǎng)上大神,純粹自己學(xué)習(xí)記錄而已,勿噴!
以上這篇BootStrap自定義popover,點(diǎn)擊區(qū)域隱藏功能的實(shí)現(xiàn)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林網(wǎng)。
新聞熱點(diǎn)
疑難解答