【发布时间】:2013-08-07 13:30:05
【问题描述】:
一切都可以在这里找到:http://jsfiddle.net/dweiliu/NBFMq/3/
这是相关代码:
$('article.weeklyStandings').each(function(){
var numPlayers = $(this).children('table tr').length;
$(this).children('h2').append(" - " + numPlayers + " Players");
});
我可能有多个数据表,其结果显示在 jsfiddle 中。我想通过查看表格中的行数来指出在任何给定的一周内参加比赛的玩家数量。
为什么 $(this).children('table tr').length; 在 jsfiddle 上返回 0?请注意,在我的本地机器上,同样的代码返回 3。
【问题讨论】:
-
.children只获取您需要使用的直系后代.find -
谢谢皮特。这是我的问题。我不知道。
标签: javascript jquery dom jquery-selectors