Creates a new row (tr) in the table, and adds the row to the rows collection.
dhtml语法
otr = object.insertrow( [iindex])
parameters
iIndex |
Optional.
Integerthat specifies where to insert the row in the rows collection. The default value is -1, which appends the new row to the end of the rows collection. |
Return Value
Returns the tr element object if successful, or null otherwise.
Remarks
If you insert a row in a tfoot, tbody, or thead, you also need to add the row to the rows collection for the table. if you insert a row in the table, you also need to add the row to the rows collection for the tbody. if you specify an index, the index should be relative to the rows collection for the element that first contains the tr. for example, if you call this method for a tbody, you must specify an index value relative to the rows collection that is on the tbody, not the table.
the preferred technique for inserting a row is to add the row at the end of the rows collection. it is faster to add a row at the end of a table than somewhere in the middle. to add a row at the end of the collection, specify the -1 value, or the length of the rows collection minus 1.
DHTML代码范例
This example uses the insertRow method to add a row to the table.
myNewRow = document.all.myTable.insertRow()
是否符合公共标准
This method is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To
更多语法参考
rowindex, rows, sectionRowIndex