首页 > append后的节点如何使用jquery插件

append后的节点如何使用jquery插件

append文章列表,然后每篇文章上有作者头像,想使用bootstrap.js 里的popover方法显示作者的详细信息。
//查看用户详情
$('body').on("mouseover",'.user-avatar',function(){
t = $(this).find('[data-popover="content"]').html();
$(this).popover({
trigger:'hover',
content:t,
html:true,
placement : 'bottom'
});
})
但每次 要第二次移动到 头像上才会出现用户资料卡!
请问如何解决?


你这个情况光是提供这个绑定方法没办法判断哪里出错了吧。

建议你安装chrome的jQuery Audit插件,然后在控制台里查看第一次mouseover之前,那个jquery对象上有没有绑定event handler。


popover的绑定是通过mouseover进行的
可以通过在页面DOMEReady后就执行绑定

//试下如下代码看看
//$('.user-avatar [data-popover="content"]').each(function(){
$('body').find('.user-avatar [data-popover="content"]').each(function(){
    $(this).popover({
    trigger:'hover',
    content:$(this).html(),
    html:true,
    placement : 'bottom'
    });
});
【热门文章】
【热门文章】