gpt4 book ai didi

javascript - 通过单击外部关闭 Bootstrap 弹出窗口

转载 作者:行者123 更新时间:2023-11-29 17:14:24 25 4
gpt4 key购买 nike

如何通过在弹出窗口外单击来关闭 Bootstrap 弹出窗口。目前它有打开链接的开关。

HTML

 <div class="widget-rating">
<span class="rateit rating-average"></span>
<a class="btn btn-mini" href="javascript:void(0)"><b class="caret"></b></a>
</div>

这是js代码

element.popoverAnchor.popover({
title: "Rating",
animation: false,
html: true,
content: "Loading...",
placement: "bottom",
trigger: "click"
});

最佳答案

$('body').on('click', function (e) {
$('.popover-link').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});

引用:http://mattlockyer.com/2013/04/08/close-a-twitter-bootstrap-popover-when-clicking-outside/

关于javascript - 通过单击外部关闭 Bootstrap 弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19158064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com