您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)BootStrap如何實現(xiàn)自定義popover,點擊區(qū)域隱藏功能的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
代碼如下
之前的按鈕必須定義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)前點擊的內(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)點擊body的非彈出框相關(guān)的內(nèi)容的時候,關(guān)閉所有popover } }); $(".pop").click(function (event) { $('.pop').popover('hide'); // 當(dāng)點擊一個按鈕的時候把其他的所有內(nèi)容先關(guān)閉。 $(this).popover('toggle'); // 然后只把自己打開。 }); });
感謝各位的閱讀!關(guān)于“BootStrap如何實現(xiàn)自定義popover,點擊區(qū)域隱藏功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。