![]() |
#2
devilqin2012-12-03 17:55
|

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. New Document </title>
<script type="text/javascript">
var oHtml = document.documentElement;
//var oHead = oHtml.firstChild;
var oHead = oHtml.firstChild;
var oBody = oHtml.lastChild;
alert(oBody.previousSibling == oHead); //output false
alert(oHead.nextSibling == oBody); //output false
</script>
</head>
<body>
<p>Hello</p>
<p>this is 2nd</p>
<p>this is 3rd</p>
<p>this is 4th</p>
</body>
</html>
<script type="text/javascript">
var oHtml = document.documentElement;
//var oHead = oHtml.firstChild;
var oHead = oHtml.firstChild;
var oBody = oHtml.lastChild;
alert(oBody.previousSibling == oHead); //output false
alert(oHead.nextSibling == oBody); //output false
</script>
</head>
<body>
<p>Hello</p>
<p>this is 2nd</p>
<p>this is 3rd</p>
<p>this is 4th</p>
</body>
</html>