在TABLE裏實現的代碼:
Function Add() //添加控件
{
var nRow=document.all.Table1.rows.length; //獲得當前TABLE的行數
var objTheRow=document.all.Table1.insertRow(nRow);//執行添加
objTheRow.insertCell(0);//添加當前行的列
//添加一個按紐控件
objTheRow.cells(0).innerHTML="<input type='button' value='delete me'onclick='Delete()'>";
}
Function Delete() //刪除控件
{
var currRowIndex=event.srcElement.parentNode.parentNode.rowIndex;//獲取當前索引
document.all.Table1.deleteRow(currRowIndex);//執行刪除
}