Javascript 引导:弹出按钮单击
我用过bootstrap的popover功能,现在可以用了。。但是如果我点击页面中的任何地方,我需要“关闭”弹出框。请检查我使用的代码 首先单击按钮,然后我需要在单击黑色空间时“关闭”弹出框(现在只有在单击同一按钮时才会关闭)Javascript 引导:弹出按钮单击,javascript,html,css,twitter-bootstrap,Javascript,Html,Css,Twitter Bootstrap,我用过bootstrap的popover功能,现在可以用了。。但是如果我点击页面中的任何地方,我需要“关闭”弹出框。请检查我使用的代码 首先单击按钮,然后我需要在单击黑色空间时“关闭”弹出框(现在只有在单击同一按钮时才会关闭) $(文档).ready(函数(){ $('[data toggle=“popover”]')。popover(); }); 这将起作用 使用下面的javascript在外部单击时关闭弹出窗口 $('body').on('click', function (e) {
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover();
});代码>
这将起作用
使用下面的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');
}
});
});
这会奏效的
使用下面的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');
}
});
});
只需在a
标记中使用data trigger=“focus”
有关更多信息,请查看
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover();
});代码>
只需在a
标记中使用data trigger=“focus”
有关更多信息,请查看
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover();
});代码>
试试这个
$(document).ready(function(){
$('[data-toggle="popover"]').popover({trigger:'focus'});
});
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({trigger:'focus'});
});代码>
试试这个
$(document).ready(function(){
$('[data-toggle="popover"]').popover({trigger:'focus'});
});
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({trigger:'focus'});
});代码>
看这里-看这里-