为什么我写前一个节点就是不显示呢?
<script type="text/javascript">
function get_nextSibling(n){
var x=n.nextSibling;
while (x && x.nodeType!=1){
x=x.nextSibling;
}
return x;
}
var x=document.getElementsByTagName("li")[1];
document.write(x.nodeName);
document.write(" = ");
document.write(x.innerHTML);
var y=get_nextSibling(x);
if(y!=null){
document.write("<br />nextsibling: ");
document.write(y.nodeName);
document.write(" = ");
document.write(y.innerHTML);
}else{
document.write("<br>已经是最后一个节点");
}
var i=get_previousSibling(x);
if(i!=null){
document.write("<br />nextsibling: ");
document.write(i.nodeName);
document.write(" = ");
document.write(i.innerHTML);
}else{
document.write("<br>已经是最后一个节点");
}