<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <ul> <li>jS</li> <li>jQuery</li> <li>PHP</li> </ul> <!-- <ul><li>jS</li><li>jQuery</li><li>PHp</li></ul> --> <script> x = document.getElementsByTagName("ul")[0].childNodes; console.log("UL子节点个数:" + x.length) console.log("节点类型:" + x[0].nodeType) //IE // UL子节点个数:3 // 节点类型:1 // 其他浏览器 // UL子节点个数:7 // 节点类型:3 </script> </body> </html>