jquery - 使用 jquery 但来自表内表的 td 值

标签 jquery html-table

我想获取 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>

最佳答案

好的,根据您的反馈,我认为这就是您所追求的。单击“执行”按钮即可查看其实际效果。

http://jsfiddle.net/mSHKC/

$('#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/

相关文章:

jquery - FancyBox 'Uncaught TypeError: Cannot call method ' 隐藏'of undefined'

javascript - 将 json 对象打印到嵌套的 html 表中

html - 表格的正确标题

html - 为什么固定表格布局 td 字不换行?

javascript - 未显示 highchart 的散点工具提示

javascript - 添加和更改类

javascript - 从 jQgrid EditURL 返回一个值

html - 增加html中td单元格的宽度和高度

javascript - 缺少字段的 Handlebars 输出为空

javascript - 在 Drupal 7 中使用 JQuery