【发布时间】:2013-08-15 04:15:26
【问题描述】:
我有一个示例代码:
<div id="fb-root"></div>
<div class="fb-comments" id="fb-comment" data-href="http://fb.com/t1" data-num-posts="3" data-width="590" ></div>
<div class="fb-comments" id="fb-comment" data-href="http://fb.com/t2" data-num-posts="3" data-width="590" ></div>
还有 javascript:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxx', // App ID
channelUrl : 'xxx', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('comment.create', function(response) {
var href = jQuery('.fb-comments').attr('data-href');
alert(href);
});
}
</script>
错误 jquery 只得到第一个值是http://fb.com/t1,没有得到http://fb.com/t2
【问题讨论】:
-
使用
jQuery.each循环遍历元素
标签: javascript jquery facebook facebook-comments