【发布时间】:2011-08-24 10:01:50
【问题描述】:
我正处于 .each 迭代的中间,想为 each 调用第二个或第三个孩子。但无法使其工作。
alert($(this + ' :nth-child(2)').attr('id'));
我能想到的唯一选择是像这样可怕的愚蠢:
$(this).children(':first').next().attr('id', 'ddParam' + newCount);
$(this).children(':first').next().next().attr('id', 'txt' + newCount);
$(this).children(':first').next().next().next().attr('id'...
【问题讨论】:
-
你试过
$(this).find(':nth-child(2)')吗? -
我没有,但现在我有了,但没有产生任何结果.. 谢谢
-
我的错 - 哈哈...在我的情况下,孩子 #2 没有 ID(因此返回空白)
标签: jquery jquery-selectors dom-traversal