<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>DOM节点关系</title> </head> <body> <p id="s"><span id="ss">b</span><a id="sss">b</a></p> </body> <script type="text/javascript"> var s=document.getElementById('s'); var ss=document.getElementById('ss'); var sss=document.getElementById('sss'); var a=s.childNodes.item(0) var aa=s.childNodes.item(1); var b=s.parentNode; var bb=ss.parentNode; var bbb=sss.parentNode; var c=ss.previousSibling; var cc=ss.nextSibling; var d=ss.ownerDocument;//该属性指向表示整个文档的文档节点 console.log(a); console.log(aa); console.log(b); console.log(bb); console.log(bbb); console.log(c); console.log(cc); console.log(d); </script> </html>