var objTable=document.getElementById( "tb_visitor" );
2、新增一行
var objTempRow = objTable.rows[0]; //取得模板行
var objNewRow = objTable.insertRow( objTable.rows.length );
objNewRow.id = objTable.rows.length-1;
//添加一行的相关信息
for ( var i=0 ; i<objTempRow.cells.length ; i++ )
{
var objNewCell = objNewRow.insertCell( i );
objNewCell.innerHTML = objTempRow.cells[i].innerHTML;
//
if(objNewCell.innerHTML.indexOf("value=")!=-1){
var si=objNewCell.innerHTML.indexOf("value=")*1+6;
var ei=objNewCell.innerHTML.indexOf(">");
var cellvalue=objNewCell.innerHTML.substring(si,ei);
//将新列内容清空且变为可用状态
objNewCell.innerHTML=objNewCell.innerHTML.replace(cellvalue,'').replace('disabled','');
}
}
//添加行的click事件
objNewRow.onclick = new Function("fn_clickrow(this);");
3、删除一行
objTable.deleteRow(objrow.index);