使用jQuery循环遍历表行中的所有单元格

时间:2014-07-28 16:02:43

标签: javascript jquery row cell

使用jQuery实现这一目标的最佳方法是什么,我试图在行单击时更改每个单元格的文本,但我无法首先访问单元格文本({{ 1}}是空的):

str

1 个答案:

答案 0 :(得分:1)

td没有值。请改用.text()

$("tr").bind("click", function() {
    $cells = $(this).children();
    $cells.each(function(cell) {
        var str = cell.text();
    });
});