Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Methods
 insertRow Method

  Switch on low bandwidth view
insertRow Method

Creates a new row (tr) in the table, and adds the row to the rows collection.

Syntax

oTR = object.insertRow( [iIndex])

Parameters

iIndex Optional. Integer that 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

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.

Example

This example uses the insertRow method to add a row to the table.

myNewRow = document.all.myTable.insertRow()

Standards Information

This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link.

Applies To

TABLE, TBODY, TFOOT, THEAD, HTMLTableElement Constructor, HTMLTableSectionElement Constructor

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
no way to add row      yecril ... Thomas Lee   |   Edit   |   Show History
Contrary to what the documentation suggests, there is no way to add an existing row to the rows collection.
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker