<tr>
<td>#</td>
<td>2009</td>
<td><a class="delete_this">Click</a></td>
</tr>我想使用jquery并在点击锚点时获得第二个(第二个) "td“的文本。我希望"td“和锚在同一个tr中...
我该怎么做呢?
到目前为止,我已经
$(document).ready(function(){
$(".delete_this').click(function(){
var myNUmber = $(this).parent()....///And this i should write the code to get the text for second td in tr where the anchor belongs to
})
})发布于 2009-08-01 00:41:32
以下是几种方法:
$(this).parent().siblings("td:eq(1)").text()如果你在这样做之前正在寻找细胞:
$(this).parent().prev().text()发布于 2009-08-01 00:28:18
$('.delete_this').closest('tr').children(':eq(1)') .text();
1)获取.delete_this A标签
2)获取父树
3)获取第二个TD
4)获取第二个TD的文本
发布于 2009-08-01 00:28:35
var myNUmber = $(this).parent().siblings().get(1).text();详情请参阅here
https://stackoverflow.com/questions/1215460
复制相似问题