我想获取 t2 类表中 td 内元素的 td 值 我怎样才能实现它? 我尝试过,但没有帮助
var test = $(.lv1 tr:nth-child(" + row2 + ")").children("td:last").children(".lv2 tr:last").children("td:last").html();
表格
<listview1>
<itemtemplate>
<table class="t1">
<tr class="lv1"><td></td><td></td></tr>
<tr class="lv1"><td colspan="2">
<listview2>
<itemtemplate>
<table class="t2">
<tr class="lv2">
<td></td>
</tr>
<tr class="lv2">
<td></td>
</tr>
</table>
</itemtemplate>
</listview2>
</td></tr>
</table>
</itemtemplate>
</listview1>
最佳答案
好的,根据您的反馈,我认为这就是您所追求的。单击“执行”按钮即可查看其实际效果。
$('#go').click( function() {
var id = 'foo'; //hardcode id retrieval on button press
//value of first td of first row in table.t2
var firstTdFirstRow = $(this).closest('table.t1').find('table.t2 tr:first td:first').html();
//value of first td of last row in table.t2
var firstTdLastRow = $(this).closest('table.t1').find('table.t2 tr:last td:first').html();
});
您有此评论,但我不确定它的含义,因为我认为您犯了拼写错误。
its selecting right td which i want to but while appenind its getting error
关于jquery - 使用 jquery 但来自表内表的 td 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8707142/