Table的tbody里用innerHTML怎么添值啊(已经疯了)
function init(){
var aaa="";
aaa = "<tr><td>ff</span></td><td>ss</td><td>ee</td><td>ee</td></tr>";
document.getElementById('result').innerHTML = aaa;
}
</script>
<BODY>
<table border="1">
<thead>
<tr>
<td >
姓名
</td>
<td >
地址
</td>
<td>
种类
</td>
<td >
价格
</td>
</tr>
</thead>
<tbody name="result" id="result">
</tbody>
</table>
<input type="button" value="ok" onclick="init()"/>
</BODY>
------解决方案--------------------
换换写法
<html>
<script>
function init(){
var aaa="";
aaa = " <tr> <td>ff </td> <td>ss </td> <td>ee </td> <td>ee </td> </tr>";
var objNewRow = tab.insertRow(tab.rows.length);
var objNewCell1 = objNewRow.insertCell();
objNewCell1.innerHTML = "ff";
var objNewCell2 = objNewRow.insertCell();
objNewCell2.innerHTML = "ss";
var objNewCell3 = objNewRow.insertCell();
objNewCell3.innerHTML = "ee";
var objNewCell4 = objNewRow.insertCell();
objNewCell4.innerHTML = "ee";
}
</script>
<body>
<table border="1" id="tab">
<tr>
<td >
姓名
</td>
<td >
地址
</td>
<td>
种类
</td>
<td >
价格
</td>
</tr>
</table>
<input type="button" value="ok" onclick="init()"/>
</body>
</html>