jQuery遍历table

1、

$("table").find("tr").each(function(){
  $(this).find("td").each(function(){
  alert($(this).text());
  });
});

 

2

var tab = document.getElementById("table1");  //找到这个表格
var rows = tab.rows; //取得这个table下的所有行
for(var i=0;i<rows.length;i++)
{
for(var j=0;j<rows[i].cells.length;j++)
{
var cell = rows[i].cells[j];
alert("第"+(i+1)+"行第"+(j+1)+"格的数字是"+cell.innerHTML);
}
}
posted @ 2014-08-29 12:06  Leon719  阅读(241)  评论(0编辑  收藏  举报