« HTML元素 - table手动关闭端口 »

deleteRow方法

语法:
object . deleteRow ( iIndex )
参数:
iIndex :  可选项。整数值(Integer)。指定从表格内删除的行的序号。如果忽略此参数,默认将删除 rows 集合内的最后一个。

返回值:

说明:
从 object 中删除指定的行(Row)。也即从 rows 集合中删除指定的项目( tr )。
指定的行从 tFoot , tBody , tHead 中删除,也同时从 table 的 rows 集合中删除。此时 iIndex 应该是表示 tr 的 sectionRowIndex 属性。
指定的行从 table 中删除,等于从 tBody 的 rows 集合中删除。此时 iIndex 应该是表示 tr 的 rowIndex 属性。
<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>&nbsp;&nbsp;&nbsp;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>
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]

相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。