Table deleteRow() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Table


The deleteRow() method removes the row by index from a table.



Parameter Values

Value Description
index Required in Firefox and Opera, optional in IE, Chrome and Safari.

-1 removes the last row will be deleted.

Return Value:

No return value

The following code shows how to Delete the first row in a table:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, td {
    border: 1px solid black;
</style>/*w  w w .  j ava  2  s  .  c o m*/

<table id="myTable">
    <td>Row1 cell1</td>
    <td>Row1 cell2</td>
    <td>Row2 cell1</td>
    <td>Row2 cell2</td>
    <td>Row3 cell1</td>
    <td>Row3 cell2</td>

<button onclick="myDeleteFunction()">Delete row</button>


function myDeleteFunction() {


Related Tutorials