jquery 遍历表格,需要表格中每个td的内容

想把这个表格每行的数据整理成json,然后push到一个数组中,这表格怎么遍历能够得到每个td的值呢?

$("table tr:gt(0)").each(function(i){
    alert("这是第"+i+"行内容");
    $(this).children("td").each(function(i){
        alert("第"+i+"个td的内容:"+$(this).text());
    });
});

温馨提示:内容为网友见解,仅供参考
第1个回答  2017-06-17
$('td').each(function(){
arr[$(this).index()] = $(this).val();
})
相似回答