JavaScript Reference/Javascript Methods/insertCell
"insertCell()" Example
<source lang="javascript">
<html> <body> <script language="JavaScript"> function function1() {
var myRow = document.all.myTable.insertRow(); var myCell = myRow.insertCell(); myCell.innerText = "The added cell";
} </script>
3 | 4 |
1 | 2 |
<button onclick="function1();">Add a cell</button> </body> </html>
</source>
"insertCell()" is applied to
<source lang="javascript">
+----------------+--------------------------------------------------------------+ | Applied_To |<tr> | +----------------+--------------------------------------------------------------+
</source>
"insertCell()" Syntax, Parameters and Note
<source lang="javascript">
Note: This method adds a cell to the specified table row.
Syntax:
document.getElementById("trID").insertCell(param1) document.all.trID.insertCell(param1) // IE only Parameters:
param1 Optional; the index of the new cell"s position. The default value is -1, which appends the cell to the end. </source>