<html>
<head runat="server">
<title>无标题页 </title>
<script type="text/javascript">
function Add(){
var s1=document.createElement("div");
//s1.firstChild.nodeValue="asd";//s1并没有firstChild,所以设置nodeValue这句出错了
//====>
s1.innerHTML="asd";
document.getElementById("div1").appendChild(s1); }
</script>
</head>
<body>
<div id="div1"></div>
<input type="button" onclick="Add()" value="添加" />
</body>
</html>
<head runat="server">
<title>无标题页 </title>
<script type="text/javascript">
function Add(){
var s1=document.createElement("div");
//s1.firstChild.nodeValue="asd";//s1并没有firstChild,所以设置nodeValue这句出错了
//====>
s1.innerHTML="asd";
document.getElementById("div1").appendChild(s1); }
</script>
</head>
<body>
<div id="div1"></div>
<input type="button" onclick="Add()" value="添加" />
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script language="JavaScript">
function addNode(){
var s1 = document.createElement("div");
s1.innerHTML = "asd";
document.getElementById("div1").appendChild(s1);
}
</script>
<body>
<input type="button" value="append" onclick="addNode();">
<hr>
<div id="div1">
</div>
</body>
</html>
s1.id="asd";
document.getElementById("div1").appendChild(s1);
var Z="添加的对象";
var S="添加的对象位置的前面";
document.body.insertBefore(Z,S); //就是把Z放在S的前面
$("#dvi1").append("<div>asd</div");
s1.innerHTML = "asd";
document.getElementById("div1").appendChild(s1);
s1.innerHTML = "asd";
document.getElementById("div1").appendChild(s1);