addRow to TABLE by using Javascript

The table object support adding row by using:
var x = document.getElementById('myTable').insertRow(0);


The method accepts a integer parameter as the row index of this table.
insertRow(0) means to insert a new row at the top of the table.
insertRow(objTable.rows.length) means to insert a new row at the bottom of the table
insertRow() will return an object of the new added TR.

While you get the TR object, you can use blow method to add each column of the row:
var y = x.insertCell(0);


Parameter of insertCell() means the column index, start from zero.


more will come....

你可能感兴趣的:(JavaScript)