【发布时间】:2013-12-26 08:13:33
【问题描述】:
使用引导弹出框,现在我试图让此代码在弹出框外部单击以关闭弹出框:
$('body').on('click', function (e) {
$('[data-toggle="popover"]').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');
}
});
});
但是当我使用这部分时,我可以关闭弹出框但我无法单击其他按钮,有人知道我该怎么做吗?
所有按钮:
<a href="#" class="btn btn-xs btn-primary" data-toggle="popover">This opens popover</a>
<a href="#" class="btn btn-xs btn-primary">Other link</a> <- Doesn't work
<a href="#" class="btn btn-xs btn-primary">Other link</a> <- Doesn't work
【问题讨论】:
-
最好检查你的
z-index我认为弹出框已经克服了一些问题 -
@RahilWazir 这有点帮助,弹出框有类 .fade 和淡入,并且 .fade 有 opacity:0 所以它仍然存在但仍然没有^^现在我需要找出如何从那里删除不透明度,因为当我这样做时,我用于关闭它的代码将不起作用
-
做个小提琴会很有帮助的。
-
不起作用是什么意思?能提供一个关于jsfiddle的demo吗?