来源:http://blog.csdn.net/bobwu/article/details/7497412
1 <HTML> 2 <head> 3 <SCRIPT LANGUAGE="JavaScript"> 4 //遍历表格的每行每列 5 function viewCell() 6 { 7 var count=1; //在表格中显示的内容 8 for (i=0; i < document.all.tbl.rows.length; i++) { //遍历每行 9 for (j=0; j < document.all.tbl.rows(i).cells.length; j++) { //遍历行中的每一列 10 document.all.tbl.rows(i).cells(j).innerText = count; //在单元格显示数值 11 count++; 12 } 13 } 14 } 15 </SCRIPT> 16 </head> 17 <BODY onload="viewCell()"> 18 <TABLE id=tbl border=1 width="200"> 19 <TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR> 20 <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> 21 <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> 22 </TABLE> 23 </BODY> 24 </HTML>
原文:http://www.cnblogs.com/huashanqingzhu/p/4340711.html