function addRow(billingTable)
{
var table = document.getElementById(billingTable);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var colCount = table.rows[0].cells.length;
for (var i = 0; i < colCount; i++)
{
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[1].cells[i].innerHTML;
// after this line the new cell is created but it also copies the
// value from the 1st row of the table.How can I set the value of
// this new cell to null or blank string ??
switch(newcell.childNodes[0].type)
{
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
}
}
}
答案 0 :(得分:1)
而不是这一行,
newcell.innerHTML = table.rows[1].cells[i].innerHTML;
你可以简单地写一下,
newcell.innerHTML = "";
答案 1 :(得分:0)
新单元格由行
创建var newcell = row.insertCell(i);
如果您希望新单元格与其他单元格不具有相同的内容,则不要将其innerHTML
分配给另一个单元格的innerHTML
。请留空。