test document.createElement 在IE和Firefox,Safari,Opera
<html>
<head></head>
<body onload="aa()">
<table id = "MyTableBoyd" name = "MyTableBoyd" border="1"><tr><td>aa</td></tr></table>
<form id="form"></form>
</body>
</html>
<script >
function aa() {
alert("ok");
//这是IE和Firefox,Safari,Opera都支持的代码
var cell = document.createElement("td").appendChild(document.createTextNode("foo"));
cell.innerHTML = "aa";
alert("cell is :" + cell);
var row = document.createElement("tr").appendChild(cell);
alert("row is :" + row);
document.getElementById("MyTableBoyd").appendChild(row);
alert("end");
}
var button = document.createElement("input");
button.setAttribute("type","button");
document.getElementById("form").appendChild(button);
var li = document.createElement("li");
li.innerHTML = "textLI";
var ul = document.createElement("ul");
ul.appendChild(li);
document.getElementById("form").appendChild(ul);
</script>