JavaScript traverses rows and columns of table

Source: Internet
Author: User

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>&nbsp;</TH><TH>&nbsp;</TH><TH>&nbsp;</TH><TH>&nbsp;</TH></TR> - <TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR> + <TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR> A </TABLE> at </BODY> - </HTML>

JavaScript traverses rows and columns of table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.