Bootstrap popover,隐藏在外部?

编程入门 行业动态 更新时间:2024-10-25 07:18:28
本文介绍了Bootstrap popover,隐藏在外部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用bootstrap popover,现在我试图使此代码在popover外部单击以关闭popover:

using bootstrap popover, and now im trying to get this code to click outside the popover to close the popover:

$('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'); } }); });

但是当我使用这部分时,我可以关闭弹出窗口,但是我不能单击其他按钮,任何人都知道我该怎么做?

But when i use this part, i can close the popover but i cant click the other buttons, anyone got any idea how i can do that?

所有按钮:

<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

推荐答案

我发现了这个问题: bootply/99372

$('body').on('click', function (e) { $('[data-toggle=popover]').each(function () { // hide any open popovers when the anywhere else in the body is clicked if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { $(this).popover('hide'); } }); });

与您的代码几乎相同...

It's almost the same code as you...

更多推荐

Bootstrap popover,隐藏在外部?

本文发布于:2023-11-23 04:37:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620118.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Bootstrap   popover

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!