Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导:弹出按钮单击_Javascript_Html_Css_Twitter Bootstrap - Fatal编程技术网

Javascript 引导:弹出按钮单击

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

我用过bootstrap的popover功能,现在可以用了。。但是如果我点击页面中的任何地方,我需要“关闭”弹出框。请检查我使用的代码

首先单击按钮,然后我需要在单击黑色空间时“关闭”弹出框(现在只有在单击同一按钮时才会关闭)

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


看这里-看这里-