The table object support adding row by using:
The method accepts a integer parameter as the row index of this table.
insertRow(0) means to insert a new row at the top of the table.
insertRow(objTable.rows.length) means to insert a new row at the bottom of the table
insertRow() will return an object of the new added TR.
While you get the TR object, you can use blow method to add each column of the row:
Parameter of insertCell() means the column index, start from zero.
more will come....
var x = document.getElementById('myTable').insertRow(0);
The method accepts a integer parameter as the row index of this table.
insertRow(0) means to insert a new row at the top of the table.
insertRow(objTable.rows.length) means to insert a new row at the bottom of the table
insertRow() will return an object of the new added TR.
While you get the TR object, you can use blow method to add each column of the row:
var y = x.insertCell(0);
Parameter of insertCell() means the column index, start from zero.
more will come....
本文介绍如何使用JavaScript操作HTML表格元素,包括在表格顶部或底部插入新行,并为这些新行添加单元格。通过简单的代码示例,读者可以快速掌握基本的表格操作技能。
692

被折叠的 条评论
为什么被折叠?



