为什么不行?
function get_nextSibling(n){
var x=n.nextSibling;
while (x && x.nodeType!=1){
x=x.nextSibling;
}
return x;
}
var x=document.getElementsByTagName("li")[0];
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>已经是最后一个节点");
}
function get_prebiousSibling(n){
var a=n.prebiousSibing;
while(a&&a.nodeType!=1){
a=a.prebiousSibing;
}
return a;
}
document.write("<br/>"+x.nodeName);
document.write(" = ");
document.write(x.innerHTML);
var c=get_previousSibling(x);
if(c!=null){
document.write("<br />previousSibling: ");
document.write(c.nodeName);
document.write(" = ");
document.write(c.innerHTML);
}else{
document.write("<br>这是第一个节点");
}
</script>
</body>
</html>