使用jQuery在每个表行的第一个TD上添加类

Rob*_*t E 7 html css jquery html-table class

我有一张我正在使用的桌子,就像这样:

<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tablecontent">
  <tr class="tablerow">
    <td>This is the td I want to add a class to.</td>
    <td class="cell2">Stuff</td>
    <td class="cell3">Stuff</td>
  </tr>
  <tr class="tablerow">
    <td>This is the td I want to add a class to.</td>
    <td class="cell2">Stuff</td>
    <td class="cell3">Stuff</td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

每行中的第一个TD标记没有要使用的类或ID.我没有权限更改HTML输出,所以我想添加一些jQuery来定位每个tablerow的第一个TD标记.我该怎么做?

use*_*716 12

$('#tablecontent td:first-child').addClass('someClass');
Run Code Online (Sandbox Code Playgroud)

这使用第一个子选择器来选择表中属于其父级的所有<td>元素.#tablecontentfirst-child

示例: http ://jsfiddle.net/duKKC/