mar*_*zzz 3 jquery facebook xfbml
我的代码:
<a id="render-me" href="javascript:void(0);">Render me</a>
<div id="social-facebook"></div>?
$('#render-me').click(function (e){
e.preventDefault();
$('#social-facebook').html("<fb:like id='button-facebook' href='http://www.google.com' send='false' layout='button_count' width='450' show_faces='false'></fb:like>");
FB.XFBML.parse(document.getElementById('button-facebook'));
});
Run Code Online (Sandbox Code Playgroud)
我点击,但按钮没有渲染.我哪里错了?
小智 9
您必须在DOM中指定一个节点.所以,你不能使用:
FB.XFBML.parse(document.getElementById('button-facebook'));
Run Code Online (Sandbox Code Playgroud)
改为使用:
FB.XFBML.parse(document.getElementById('social-facebook'));
Run Code Online (Sandbox Code Playgroud)
它会工作正常;)
尝试添加此标记
<div id="fb-root"></div>
Run Code Online (Sandbox Code Playgroud)
在页面底部,并确保添加FB脚本.请看一下图片

请按照以下步骤操作,您将能够解决您的问题.
欲了解更多信息,请浏览此链接 https://developers.facebook.com/docs/reference/plugins/like/
| 归档时间: |
|
| 查看次数: |
8969 次 |
| 最近记录: |