这是我的代码示例..从示例中,我有两行..我想做的是,我想动态添加这两行..谢谢
<table id="datatable">
<tr>
<td><input type="text" /></td>
</tr>
<tr>
<td><input type="text" /></td>
</tr>
</table>
<button type="button" id="add" onclick="addRow('dataTable')">
<b>Add</b>
</button>
function addRow(tableID) {
alert('ttt');
var table = document.getElementById(tableID);
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[0].cells[i].innerHTML;
//alert(newcell.childNodes);
switch(newcell.childNodes[0].type) {
case "text":
newcell.childNodes[0].value = "";
break;
case "checkbox":
newcell.childNodes[0].checked = false;
break;
case "select-one":
newcell.childNodes[0].selectedIndex = 0;
break;
}
}
}