如何解决在外部单击时使用 HTML 关闭弹出窗口,无需双击重新打开
是的,还有一个关于它的问题,因为它应该在本地工作。我咨询了几个问题,例如:
Close popover with HTML on click outside
Bootstrap Popover Doesn't Close on Clicking Outside
Hide Bootstrap Popover when clicked outside of the popover
How to dismiss a Twitter Bootstrap popover by clicking outside?
详细信息:我的弹出窗口中有 4 个多选。 它关闭,但只有在第二次点击后才会打开
有人说这段代码可以解决问题,但由于这段代码,当我在外面单击时它甚至不会关闭:
$(document).on("shown.bs.popover",'[data-toggle="popover"]',function(){
$(this).attr('someattr','1');
});
$(document).on("hidden.bs.popover",'0');
});
$(document).on('click',function (e) {
$('[data-toggle="popover"],[data-original-title]').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) {
if($(this).attr('someattr')=="1"){
$(this).popover("toggle");
}
}
});
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。