ZVON > References > DOM2 Reference

deleteCell (method )

Owning interface and usage:  
HTMLTableRowElement.deleteCell(index)

Member of these other interfaces:  
none

Description:  
Delete a cell from the current row.

Parameters:  
long index  -  The index of the cell to delete, starting from 0. If the index is -1 the last cell in the row is deleted.

Returns:  
nothing

Exceptions:  
DOMException INDEX_SIZE_ERR
Raised if the specified index is greater than or equal to the number of cells or if the index is a negative number other than -1.


Example:
Source:
  <TABLE id="testTable" border="1">
    <TR>
      <TD>cell 1</TD>
      <TD>cell 2</TD>
      <TD>cell 3</TD>
    </TR>
  </TABLE>
JavaScript:
  function deleteCellOnTableRow() {
    var main = document.getElementById('testTable');
    var row = main.rows.item(0);
    row.deleteCell(1);
  }
Try it:  
See it:
cell 1 cell 2 cell 3