JavaScript Reference/Javascript Methods/insertCell
Версия от 18:30, 25 мая 2010; (обсуждение)
"insertCell()" Example
<html>
<body>
<script language="JavaScript">
function function1() {
var myRow = document.all.myTable.insertRow();
var myCell = myRow.insertCell();
myCell.innerText = "The added cell";
}
</script>
<table id="myTable" border="1" cellspacing="5" cellpadding="5">
<tr>
<td width="100">3</td>
<td width="100">4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
</tr>
</table>
<button onclick="function1();">Add a cell</button>
</body>
</html>
"insertCell()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<tr> |
+----------------+--------------------------------------------------------------+
"insertCell()" Syntax, Parameters and Note
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.