Bootstrap弹出窗口不适用于第一个mouseenter事件

我使用如下代码

this 

我按如下方式触发了jquery事件

 $(document).on("mouseenter",".reply",function(event){ $(this).popover({placement:'bottom'}); }); 

但问题出在第一个hover事件上,popover没有显示出来

从第二次事件popover得到正常显示…这种活动的原因是什么以及如何纠正它…

你需要添加trigger: 'hover'trigger: 'manual'到popover的选项..个人而言,我会用以下内容替换你的javascript。

 $(function(){ $('.reply').popover({ placement: 'bottom', trigger: 'hover' }) }) 

编辑,如果你必须使用你设置的javascript,试试这个

 $(document).on("mouseenter",".reply",function(event){ $(this).popover({ placement:'bottom', trigger: 'hover' }).popover('show'); }); 

我找到答案添加以下代码使其工作

 $(document).on("mouseenter",".reply",function(event){ $(this).popover({placement:'bottom'}); $(this).popover('toggle'); }); 

您应该使用selector属性来委派Popover插件( 请参阅docs )。 像这样:

 $('body').popover({ placement: 'bottom', trigger: 'hover', selector: '.reply' }); 

注意:在实践中,建议使用比'body'更窄的代表。

只需选择您的元素,然后使用hover调用popover

 $("[rel=popover]").popover({trigger:"hover"});