You are here: Reference > JavaScript > client-side > HTML DOM > methods > deleteCell (tr)

deleteCell method (tr)

Browser support:
Removes a cell from the current row.
To create and insert a cell, use the insertCell method.


object.deleteCell (index);
You can find the related objects in the Supported by objects section below.


Required in Firefox and Opera, optional in Internet Explorer, Google Chrome and Safari. Zero-based integer that specifies the position of the cell to delete in the cells collection of the current row. The value of -1 can also be used; in that case, the last cell will be deleted. If this parameter is not specified, the deleteCell method removes the last cell in Internet Explorer and the first cell in Google Chrome and Safari.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the deleteCell method:
    <script type="text/javascript">
        function RemoveCell () {
            var table = document.getElementById ("myTable");
            var firstRow = table.rows[0];
            if (firstRow.cells.length > 0) {
                firstRow.deleteCell (0);
    <button onclick="RemoveCell ();">Remove the first cell!</button>
    <table id="myTable" border="1px">
                <td>First cell in the row.</td>
                <td>Second cell in the row.</td>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content