Office development
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

insertCell method

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

Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5

 

Syntax

var retval = tr.insertCell(index);

Parameters

index [in, optional]

Type: Integer

Integer that specifies where to insert the cell in the tr. The default value is -1, which appends the new cell to the end of the cells collection.

Return value

Type: Object

Returns the td element object if successful, or null otherwise.

Standards information

Remarks

The preferred technique for inserting a cell is to add the cell at the end of the cells collection. It is faster to add a cell at the end of a row than somewhere in the middle. To add a cell at the end of the collection, specify the -1 value, or the length of the cells collection minus 1.

Examples

This example uses the insertCell method to add a cell to the end of the tr.


myNewCell = document.all.myTable.rows[0].insertCell() 

See also

tr
Reference
deleteCell
insertRow

 

 

Show:
© 2016 Microsoft