<body>
<table id = "myTable" border="1">
<tbody id = "myTableBody"></tbody>
</table>
<script type="text/javascript">
var cell = document.createElement("td").appendChild(document.createTextNode("foo"));
var row = document.createElement("tr").appendChild(cell);
document.getElementById("myTableBody").appendChild(row);
</script>
</body>
为什么在IE中显示不出来?
<table id = "myTable" border="1">
<tbody id = "myTableBody"></tbody>
</table>
<script type="text/javascript">
var cell = document.createElement("td").appendChild(document.createTextNode("foo"));
var row = document.createElement("tr").appendChild(cell);
document.getElementById("myTableBody").appendChild(row);
</script>
</body>
为什么在IE中显示不出来?
function fnAppend(){
var cell = document.createElement("<TD>");
var row = document.createElement("<TR>");
document.getElementById("myTableBody").appendChild(row);
row.appendChild(cell);
cell.appendChild(document.createTextNode("foo"));}
</script><body>
<table id = "myTable" border="1">
<tbody id="myTableBody">
</tbody>
</table><INPUT
TYPE = "button"
VALUE = "Append Child"
onclick = "fnAppend()">
</body>
function fnAppend(){
var cell = document.createElement("<TD>");
var row = document.createElement("<TR>");
myTableBody.appendChild(row);
row.appendChild(cell);
cell.innerText="foo";}
</script><body>
<table id = "myTable" border="1">
<tbody id="myTableBody">
</tbody>
</table><INPUT
TYPE = "button"
VALUE = "Append Child"
onclick = "fnAppend()">
</body>