选择第三个< td>使用jQuery吗? [英] Select the 3rd <td> using jQuery?
本文介绍了选择第三个< td>使用jQuery吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一行有一个表,该行中有多个tds,就像这样:
I have a table a row and multiple tds in that row, like that:
<tr class="first odd">
<td class="a-center">
<td>...</td>
<td>...</td> --> I want this
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
我能够获得所有tds的父tr,但是有没有办法只获得tr内的第三个td?
I am able to get the parent tr of all the tds, but is there a way to get the 3rd td inside the tr only?
获取tr的代码是:
jQuery('#shopping-cart-table > tbody > tr').each(function(index, value) {
...
});
谢谢
推荐答案
您可以使用:eq
选择器:
jQuery('#shopping-cart-table > tbody > tr').each(function(index, value) {
$('td:eq(2)', this)
});
或者:
jQuery('#shopping-cart-table tbody').find('td:eq(2)');
这篇关于选择第三个< td>使用jQuery吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文