JavaScript deleteCell() Method Tutorial

In this section, we will learn that the deleteCell() method is and how to use it in JavaScript.

JavaScript delete cell: deleteCell() Method

The JavaScript deleteCell() method is used to remove a cell from a <tr> element of a table.

You should know that this method could only be invoked on a reference to a table row! This means you can’t use a reference to a table and invoke this method directly on that table.

Note: you could use the insertCell() method to insert a new cell to a table row.

deleteCell() Method Syntax:

tableRow.deleteCell(index);

deleteCell() Method Parameter

The method takes one argument and that is the index number of the cell that we want to remove from the target table row.

The value 0 means the first cell of the target row.

The value -1 means the last cell of the target row.

deleteCell() Method Return Value

This method does not return a value.

Example: delete cell JavaScript

See the Pen delete cell JavaScript by Omid Dehghan (@odchan1) on CodePen.

Leave a Reply