引导:点击弹出窗口按钮
Bootstrap: popover button click
我已经使用了bootstrap弹出窗口功能,它现在工作。但我需要"解散"弹出框,如果我点击页面的任何地方。请检查我使用的代码
首先点击按钮,然后我需要在点击黑色空间时"解散"弹出框(现在只有当我们点击同一按钮时才会解散)。
$(document).ready(function() {
$('[data-toggle="popover"]').popover();
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container" style="width:400px; height:400px; background:#000;padding-top:50px;">
<a href="#" title="Header" data-toggle="popover" data-content="Some content" class="btn btn-danger">Click here</a>
<br>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
在a
标签中使用data-trigger="focus"
查看更多信息请检查Dismissible popover
$(document).ready(function() {
$('[data-toggle="popover"]').popover();
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container" style="width:400px; height:400px; background:#000;padding-top:50px;">
<a href="#" title="Header" data-toggle="popover" data-content="Some content" class="btn btn-danger" data-trigger="focus">Click here</a>
<br>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
可以了
使用下面的javascript在外部点击
时解散弹出窗口$('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');
}
});
});
试试这个
$(document).ready(function(){
$('[data-toggle="popover"]').popover({trigger:'focus'});
});
$(document).ready(function(){
$('[data-toggle="popover"]').popover({trigger:'focus'});
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" style="width:400px; height:400px; background:#000;padding-top:50px;">
<a href="#" title="Header" data-toggle="popover" data-content="Some content" class="btn btn-danger">Click here</a><br>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 如何调整信息窗口的大小并点击按钮?+更改信息窗口的内容
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- 如何在单击“提交”按钮时为“新建”窗口编写JavaScript,用“确定”和“取消”显示注册信息
- 如何在Ol3弹出窗口中添加用javascript创建的按钮上的点击事件
- 在窗口中单击按钮完成之前,光标不会停止.请继续卸载
- 如何隐藏谷歌地图Api 3中InfoBox窗口中的关闭(x)按钮
- 单击按钮时的窗口属性
- 单击谷歌地图信息窗口按钮
- Angular.js谷歌地图信息窗口按钮点击没有传递值
- 谷歌地图信息窗口按钮未显示
- 引导:弹出窗口按钮链接不工作
- 引导:点击弹出窗口按钮
- 使用angular验证引导模式窗口按钮点击时的输入字段
- 关闭当前的弹出窗口按钮点击在顶点使用salesforce
- 关闭窗口按钮- javascript
- 使用iFrame's OnSubmit函数为父窗口's按钮's OnClick事件
- jQuery UI模态弹出窗口-按钮点击
- jQuery UI模态弹出窗口按钮点击
- 以编程方式弹出“打开”窗口.按钮不工作在我的mapbox.js地图我已经创建