Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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
Jquery Bootstrap Popover输入字段_Jquery_Twitter Bootstrap - Fatal编程技术网

Jquery Bootstrap Popover输入字段

Jquery Bootstrap Popover输入字段,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,是否可以在用户单击输入字段时触发popover事件,然后在用户单击其他字段时禁用它?这是我所拥有的,但当用户单击另一个字段时,它不会禁用 <input id="example" /> <script> $(document).ready(function() { $(function () { $("#example").popover({title: 'Twitter Bootstrap Popover', content: "It's

是否可以在用户单击输入字段时触发popover事件,然后在用户单击其他字段时禁用它?这是我所拥有的,但当用户单击另一个字段时,它不会禁用

 <input id="example" />

 <script>
  $(document).ready(function() {
    $(function ()  
      { $("#example").popover({title: 'Twitter Bootstrap Popover', content: "It's so simple to create a tooltop for my website!"});  
    });  
   });
 </script> 

$(文档).ready(函数(){
$(函数()
{$(“#示例”).popover({title:'Twitter Bootstrap popover',内容:“为我的网站创建工具提示太简单了!”);
});  
});

当用户在另一个输入字段中单击时,如何禁用此popover?谢谢大家!

隐藏它的一个简单方法是订阅
blur

$(function () {
    $("#example")
        .popover({ title: 'Twitter Bootstrap Popover', content: "It's so simple to create a tooltop for my website!" })
        .blur(function () {
            $(this).popover('hide');
        });
});

假设你的链接是

<a href="#foo" id="bas">bar<a>
您可以使用“触发器”隐藏“popover”


$(文档).ready(函数(){
$(函数()
{
$(“#contato”).popover({title:'Twitter Bootstrap popover',trigger:'focus',content:“为我的网站创建工具提示太简单了!”);
});  
});

我对Christoffers的答案进行了一些测试,并将其最小化:

$('#element').popover({ trigger: 'focus', title: 'Twitter Bootstrap Popover', content: "It's so simple to create a tooltop for my website!" })

我认为使用HTML5更容易:

$(document).ready(function () {
    $('#example').popover();
}

<input id="example" type="text" data-toggle="popover" data-trigger="focus" data-placement="right" data-content="It's so simple to create a tooltop for my website!" />
$(文档).ready(函数(){
$(“#示例”).popover();
}

注意,
$(处理程序)
相当于
$(文档).ready(处理程序)
,因此无需同时使用这两个选项:添加奖金;当您两次单击输入字段时,弹出框不会消失。这正是我需要的!
$('#element').popover({ trigger: 'focus', title: 'Twitter Bootstrap Popover', content: "It's so simple to create a tooltop for my website!" })
$(document).ready(function () {
    $('#example').popover();
}

<input id="example" type="text" data-toggle="popover" data-trigger="focus" data-placement="right" data-content="It's so simple to create a tooltop for my website!" />