Javascript code-javascript tips for dynamically creating and deleting tables

Source: Internet
Author: User
Generate a 2000*5 table. The content of each cell is the row number + comma + column number. The specific implementation process is as follows. If you are interested, refer, we hope to help you generate a 2000*5 table. The content of each cell is the row number, comma, and column number.

Method 1: Use createElement to generate a table, use insertRow and insertCell to generate rows and columns, and use innerHTML to populate the content of cells.
Method 2: Use createElement to generate a table and CreateElement to generate rows and columns. The content of the cell is filled with the createTextNode method.
Method 3: concatenate a string in the innerHTML attribute of the table and use the string plus = Operator to link the string.
Method 4: concatenate the string of the innerHTML attribute of the table, append each string to the array, and call the join method of the array to generate the target string.

Run Time Comparison:
Method running time (MS)
Method 1 93037
Method 2 3341
Method 3 2795
Method 4 500

The specific procedure is as follows:

The Code is as follows:




Test page

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.