我试图向特定类内的tr中的第一个td添加一个类。但由于某种原因它增加了这个类仅在每个TR如何将类添加到使用jQuery的表内的每个tr中的第一个td
$("#appendTD").find("#gridFormInformation").children(0).children().each(
function() {
if ($("#appendTD").find('tr').filter(function() { return $(this).attr('class') == 'ui-widget-content ui-subtblcell'; }).children("td:eq(0)").addClass("leftbord"));
}
);
但是,当我改变上述通过删除“在第一TR -not第一TD第一TD” TD:当量(0)”它增加了这个类在每个TR每个TD ...那我下面
<td id="appendTD">
<table id="gridFormInformation">
<tbody>
<tr><th>1</th><th>2</th><th>3</th></tr>
<tr class="ui-widget-content ui-subtblcell"><td>1</td><td>2</td><td>3</td></tr>
<tr class="ui-widget-content ui-subtblcell"><td>1</td><td>2</td><td>3</td></tr>
<tr class="ui-widget-content ui-subtblcell"><td>1</td><td>2</td><td>3</td></tr>
</tbody>
</table>
</td>
正是我一直在寻找的呢!谢谢 :-) – 2011-01-14 05:16:25