test document.createElement 在IE和Firefox,Safari,Opera

it2022-05-09  22

<html> <head></head>

<body οnlοad="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>

转载于:https://www.cnblogs.com/nanshouyong326/archive/2008/05/26/1207918.html

相关资源:数据结构—成绩单生成器

最新回复(0)