javascript当中delTRTDIEFF的用法
例 2.5(delTRTDIEFF.html)
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
<HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<TITLE> </TITLE>
</HEAD>
<BODY>
<input id="row" type="text" size="2"/>行,
<input id="dellastrow" type="button" value="删行"/><br/>
<input id="column" type="text" size="2"/>列
<input id="delrowcell" type="button" value="删最后一行的某一格"/><br/><br/>
<TABLE id="test" border="1" style="border-collapse:collapse">
<TR>
<TD>11</TD>
<TD>12</TD>
<TD>13</TD>
<TD>14</TD>
</TR>
<TR>
<TD>21</TD>
<TD>22</TD>
<TD>23</TD>
<TD>24</TD>
</TR>
<TR>
<TD>31</TD>
<TD>32</TD>
<TD>33</TD>
<TD>34</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<script>
var tab = document.getElementById("test");
function dellastrow()
{
/*
TABLE.deleteRow(anIndex) (Method)
Deletes a specified row within the TABLE object.
Argument list: anIndex The row to delete
*/
var row = document.getElementById("row").value ;
tab.deleteRow(row - 1);
}
function delrowcell()
{
var column = document.getElementById("column").value ;
var rowList = tab.rows;
var lastRow = rowList.item(rowList.length - 1);
/*TR.deleteCell() (Method)
In a multiple column table, you can delete a particular cell within a row with this method.
*/
lastRow.deleteCell(column - 1);
}
document.getElementById("dellastrow").onclick=dellastrow;
document.getElementById("delrowcell").onclick=delrowcell;
</script>