deleteRow() 方法用于从表格删除指定位置的行。
tableObject.deleteRow(index)
参数 index 指定了要删除的行在表中的位置。行的编码顺序就是他们在文档源代码中出现的顺序。<thead> 和 <tfoot> 中的行与表中其它行一起编码。
The following example deletes the first row of the table:
<html><head><script type="text/javascript">function delRow() { document.getElementById('myTable').deleteRow(0)
}</script></head><body><table id="myTable" 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>
联系客服