The following is a detailed analysis of the use of the firstChild and lastChild elements of the children object array in dom. For more information, see
The Code is as follows:
Row 1 column 1 |
Row 1 column 2 |
Row 2 column 1 |
Row 2 column 2 |
Script
Alert (test. children [0]. tagName)
Alert (test. children [1]. tagName)
Script
Document. all. tbl. children (0). children (0). Explanation of innerHTML
Document. all. tbl. children (0) locates the first subnode of the table.
Document. all. tbl. children (0). children (0) locates the first subnode of the first subnode of the table., Print the resultRow 1 column 1Row 1 column 2
Document. all. tbl. children (0). children (1). innerHTML, print the resultRow 2 column 1Row 2 column 2
Document. all. tbl. children (0). children (1). children (0). innerHTML prints the result row, 2 columns, and 2 columns.
Row 2 column 1
Row 1 column 1 |
Row 1 column 2 |
Row 2 column 2 |
Script
Alert (test. firstChild. tagName)
Alert (test. lastChild. tagName)
Script
Document. all. tbl. firstChild locates the first subnode of the table.
Document. all. tbl. firstChild. firstChild locates the first subnode of the table.
The first subnode
Document. all. tbl. firstChild. firstChild. innerHTML:Row 1 column 1Row 1 column 2
Document. all. tbl. firstChild. lastChild locates the first subnode of the table.
The last sub-node
Document. all. tbl. firstChild. lastChild. innerHTML: Row 2 column 1Row 2 column 2
Document. all. tbl. firstChild. lastChild. firstChild. innerHTML:
Row 2 column 2