<!DOCTYPE html>
 <html lang="en">
 <head>
 <meta charset="UTF-8">
 <title>增删改节点</title>
 <script>
 window.οnlοad=function () {
 var bodyNode=document.getElementsByTagName('body')[0];
 alert(bodyNode);
 var divNode=document.createElement("div");/*创建一个元素*/
 /*设置属性名和值*/
 divNode.setAttribute("style",'width:300px;height:300px;background:red');
 bodyNode.appendChild(divNode); //在元素添加一个元素
 var inputNode=document.createElement('input');
 var buttonNode=document.createElement('button');
 divNode.appendChild(inputNode);
 divNode.appendChild(buttonNode);
buttonNode.parentNode.removeChild(buttonNode);
 var inputNameNode=document.getElementsByName('username')[0];
 var name=inputNameNode.getAttribute('name');/*获取元素的属性值*/
 alert(name);
 }
 </script>
 </head>
<body>
<input type="text" name="username">
</body>
</html>










