如果你是真的学习请把下面的敲一遍
<div id="divid">
<p id="pid">div内的p元素</p>
nihaoya
</div>
function getParentNode(){
var childNode=document.getElementById("pid");
var parentnode = childNode.parentNode;
alert(parentnode.nodeName);
}
function createElementNode(){
var body=document.body;
var input=document.createElement("input");
input.type="button";
input.value="按钮";
input.onclick=function(){
alert("我是使用document.createElement("input")创建的一个按钮");
}
body.appendChild(input);
}
function createTextNode(){
var body=document.body;
var text=document.createTextNode("wojiaoyangmaotou");
body.appendChild(text);
}
function insertBefore(){
var div=document.getElementById("divid");
var pid=document.getElementById("pid");
var childnode=document.createTextNode("输入的用户名或密码错误");
div.insertBefore(childnode,pid);
}
function removechild(){
var div=document.getElementById("divid");
var pid=document.getElementById("pid");
div.removeChild(pid);
}
function getsize(){
var width=document.body.offsetWidth||document.documentElement.offsetWidth;
var height=document.body.offsetHeight||document.documentElement.offsetHeight;
alert(width+","+height);
}
//getParentNode();
//createElementNode();
//createTextNode();
//insertBefore();
//removechild();
getsize();