HTML DOM insertRow() Method
Complete Table Object Reference
Definition and Usage
The insertRow() method is used to insert a new row at the specified position in a table.
Syntax
tableObject.insertRow(index)
|
Example
The following example inserts a new row at the beginning of the table:
<html>
<head>
<script type="text/javascript">
function insRow()
{
document.getElementById('myTable').insertRow(0)
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
</table>
<br />
<input type="button" onclick="insRow()"
value="Insert new row">
</body>
</html>
|
Try-It-Yourself Demos
Add a new row to a table - then add content to it
Complete Table Object Reference
…
|