Source: http://blog.csdn.net/bobwu/article/details/7497412
1 <HTML>2 <Head>3 <SCRIPTLANGUAGE= "JavaScript">4 //iterate through each row of a table5 functionViewcell ()6 {7 varCount=1; //what is displayed in the table8 for(i=0; I<document.all.tbl.rows.length; I++) { //traverse each row9 for(J=0; J<document.all.tbl.rows (i). Cells.length; J++) { //iterate through each column in a rowTen document.all.tbl.rows (i). Cells (j). InnerText=count; //display values in cells One Count++; A } - } - } the </SCRIPT> - </Head> - <BODYonload= "Viewcell ()"> - <TABLEID=tblBorder=1width= "$"> + <TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR> - <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> + <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> A </TABLE> at </BODY> - </HTML>
JavaScript traverses rows and columns of table