Javascript FB.XFBML.parse Uncaught[对象]
为什么这不起作用Javascript FB.XFBML.parse Uncaught[对象],javascript,jquery,facebook,Javascript,Jquery,Facebook,为什么这不起作用 $('.fb-like-button').each (function(){ if ($(this).html() == "" || !$(this).html() || $(this).html() == "undefined") { $(this).html('<fb:like href="'+$(this).attr("data-url")+'" layout="button_count" send="false" s
$('.fb-like-button').each (function(){
if ($(this).html() == "" || !$(this).html() || $(this).html() == "undefined")
{
$(this).html('<fb:like href="'+$(this).attr("data-url")+'" layout="button_count" send="false" show_faces="false" width="100" action="like" font="verdana" colorscheme="light" />');
FB.XFBML.parse($(this));
$(this).attr("class", "done");
}
});
$('.fb-like按钮')。每个(函数(){
如果($(this.html()==“”| |!$(this.html()| |$(this.html()==“未定义”)
{
$(this.html(“”);
FB.XFBML.parse($(this));
$(this.attr(“class”,“done”);
}
});
错误:取消捕获[object object]好的,我找到了解决方案。我不知道为什么,但这是有效的:
FB.XFBML.parse($(this).get(0));
$(this.attr(“数据url”)你能提醒这个并检查url吗?是的,我做了:console.log($(this.attr(“数据url”))并且url是正确的。错误在这里:FB.XFBML.parse($(this));原因:parse()正在等待DOM元素对象作为参数,而不是jQuery对象。