各位,请抽出30秒来看一下我动态添加表格为什么不成功?也许是当局者迷吧,我都检查了好几遍了.
<script type= "text/javascript ">
function addTableContent()
{
var row=document.createElement( "tr ");
var cell=createCellWithText( "王二 ");
row.appendChild(cell);
cell=createCellWithText( "李小龙 ");
row.appendChild(cell);
document.getElementById( "result ").appendChild(row);
}
function createCellWithText(text)
{
var cell=document.createElement( "td ");
var textNode=document.createTextNode(text);
cell.appendChild(textNode);
return cell;
}
</script>
</head>
<body>
<table id= "result " width= "75% " border= "0 ">
<tbody id= "result ">
</tbody>
</table>
<br>
<input type=button onclick= "addTableContent() " value= "添加一行 ">
</body>
</html>
------解决方案--------------------这样就行了