在html表中循环并获取每个tr的每个td的值

时间:2014-11-28 18:26:07

标签: javascript jquery

我在html中有一个表格,我希望使用jquery获取每个td的{​​{1}}的值,我无法这样做,因为我不能要找到怎么做,这是我的表结构

tr

2 个答案:

答案 0 :(得分:1)

您可以使用.each

遍历所有行和单元格
$(function () {
    $('table tr').each(function () {
        $(this).find('td').each(function () {
            console.log($(this).text());
        });
    });
});

答案 1 :(得分:0)

像这样:

$('table tr td').each(function(){console.log($(this).text())});
相关问题