添加节点

 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2<html xmlns="http://www.w3.org/1999/xhtml" >
 3<head>
 4    <title>无标题页</title>
 5    
 6    <script type="text/javascript" language="javascript">
 7      
 8       window.onload=initAll;
 9       
10       function initAll()
11        {
12          document.getElementById("addNode").onclick=addNode;
13          return false;
14        }

15        
16        function addNode()
17        {
18          var inText=document.getElementById("TextArea1").value;
19          var newText=document.createTextNode(inText);
20          var newGraf=document.createElement("p");
21          newGraf.appendChild(newText);
22          var docBody=document.getElementsByTagName("body")[0];
23          docBody.appendChild(newGraf);
24        }

25    
26    
</script>
27    
28</head>
29<body>
30    <br />
31    <br />
32    <textarea id="TextArea1" style="width: 380px; height: 106px"></textarea><br />
33    <br />
34    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
35    &nbsp; &nbsp;
36    <input id="addNode" type="button" value="添加" onclick="addNode();" />
37    <div id="midifiArea">
38    </div>
39    <br />
40
41</body>
42</html>
43

posted on 2008-05-03 22:31  鱼跃于渊  阅读(128)  评论(0编辑  收藏  举报

导航