One, the HTML DOM.
HTML DOM features and methods are specific to the HTML, each node in the HTML is an object, by accessing the properties and methods, to make some DOM operations more convenient, in the HTML DOM is specifically used to deal with the white oh and its elements of the properties and methods.
HTML DOM Reference manual
Here is an example table for the HTML DOM Dynamic operation table.
1. Table Object (table)
In the HTML DOM, the Table object represents an HTML table, the TableRow object represents the rows of the HTML table, and the TableCell object represents the cells of the HTML table. HTML tables can be created in HTML using table, TableRow, and TableCell.
Property:
Rows[]: Gets all the rows in the table.
Cellls[]: Gets all the cells in the table.
Method:
Inertrow (Index): used to insert a new row at the specified position in the table.
DeleteRow (Index): Used to remove rows from a table at a specified location.
2. TableRow Object (line)
Property:
Cells[]: Returns all cells in the current row.
RowIndex: Returns the subscript for the current row.
Method:
InsertCell (Index): Inserts a cell at the specified position in a row.
Deletecell (Index): Deletes the cell at the specified position in a row.
3. TableCell object (cell)
Property:
CellIndex: Returns the subscript where the current cell is located
InnerHTML: Returns the HTML tag in the current cell.
Align: Sets the horizontal alignment of the cell.
ClassName: Sets the class property of the cell.
Example:
Dynamically generates rows of cells and assigns values to cells.
<HTML><Head><Scripttype= "Text/javascript">functionInsrow () {varx=document.getElementById ('myTable'). InsertRow (0) vary=X.insertcell (0) varZ=X.insertcell (1) y.innerhtml="NEW CELL1"z.innerhtml="NEW CELL2" }</Script></Head><Body><TableID= "MyTable"Border= "1"><TR><TD>Row1 Cell1</TD><TD>Row1 cell2</TD></TR><TR><TD>Row2 Cell1</TD><TD>Row2 cell2</TD></TR><TR><TD>ROW3 Cell1</TD><TD>ROW3 cell2</TD></TR></Table><BR/><inputtype= "button"onclick= "Insrow ()"value= "Insert Row"></Body></HTML>
Java Script Basics (vii) HTML DOM model