最佳答案:
index指定了要删除的行在表中的位置。行的编码顺序就是他们在文档源代码中出现的顺序。<thead>和<tfoot>中的行与表中其它行一起编码。
详情介绍
index指定了要删除的行在表中的位置。行的编码顺序就是他们在文档源代码中出现的顺序。<thead>和<tfoot>中的行与表中其它行一起编码。

- 中文名
- deleteRow
- 实例
- var i_nowheight=280;
- 可选项
- 整数值Integer
deleteRow英语释义
语法:
object . deleteRow ( index )
deleteRow() 方法用于从表格删除指定位置的行。
tableObject.deleteRow(index)说明
参数:
index :可选项。整数值(Integer)。指定从表格内删除的行的序号。如果忽略此参数,默认将删除 rows 集合内的最后一个。
返回值:
无
说明:
从 object 中删除指定的行(Row)。也即从 rows 集合中删除指定的项目( tr )。
指定的行从 tFoot , tBody , tHead 中删除,也同时从 table 的 rows 集合中删除。此时 index 应该是表示 tr 的 sectionRowIndex 属性。
指定的行从 table 中删除,等于从 tBody 的 rows 集合中删除。此时 index 应该是表示 tr 的 rowIndex 属性。
deleteRow实例1
<script>
var i_nowheight=280;
function rdl_doOver(e){
event.cancelBubble=true;
with (event.srcElement.parentElement) {
if (tagName.toLowerCase()=="tr") {
document.all("id_note").innerHTML="选定的行在<font color=#FF3300>"+parentElement.tagName.toUpperCase()+"</font>中。<br>"+"sectionRowIndex=<b>"+sectionRowIndex.toString()+"</b> rowIndex=<b>"+rowIndex.toString();+"</b>";
} else { document.all("id_note").innerHTML="请将鼠标移到上方的表格中查看信息。<br>单击将删除选定的行。";}
}
}
document.onmouseover=rdl_doOver;
function rdl_delRow(e){
event.cancelBubble=true;
with (event.srcElement.parentElement) {
if (tagName.toLowerCase()=="tr") myTable.deleteRow(rowIndex);
i_nowheight-=20;
window.resizeTo(360,i_nowheight);

}
}
</script>
<table cellspacing=1 id=myTable onclick="rdl_delRow();">
<thead><tr id=myTR><td>THEAD的第1个TD</td><td>THEAD的第1个TD</td><td>THEAD的第1个TD</td></tr></thead>
<tbody><tr id=myTR><td>TBODY的第1个TD</td><td>TBODY的第2个TD</td><td>TBODY的第3个TD</td></tr>
<tr id=myTR><td>TBODY的第4个TD</td><td>TBODY的第5个TD</td><td>TBODY的第6个TD</td></tr></tbody>
<tfoot><tr id=myTR><td>TFOOT的第1个TD</td><td>TFOOT的第1个TD</td><td>TFOOT的第1个TD</td></tr></tfoot>
</table>
<br><div id=id_note></div>
deleteRow实例2
The following exle deletes the first row of the table:<html>
<head>
<script type="text/javascript">
function delRow()
{
document.getElementById('myTable').deleteRow(0)
}
</script>
</head>
<body>
<table 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="delRow()"
value="Delete first row">
</body>
</html>


