开发者

Select table cells w/ jQuery

How do I select all but the first TDs? I don't know how many columns there could be in the table, so I can't really use :nth-child(2) etc...

<table>
<tr>
    <td>do not select</td>
    <td>select</td>
    <td>select</t开发者_如何学运维d>
    <td>select</td>
    ...
</tr>
</table>


Try this using :gt(0) which select all elements at an index greater than index within the matched set.

$("table td:gt(0)");

Working demo


$allTableCellsButFirst = $('table tr td').not('tr:first-child td:first-child');

Should do the trick for you.

Working Example via jsFiddle


$('table tr td:first-child').siblings();


You could add a class to your TD's:

$('#someTable .tableCell').each(function()
{
    alert($(this).html());
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜