dom 中的换行符
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <script>
//dom块级元素间隔中换行符被解析为文本节点 window.onload=function(){ var ps = document.getElementsByTagName("p") var p = ps[0] console.log(p.nodeName) //获取下一个元素 var hh = p.nextSibling //输出类型 换行符 console.log(hh.nodeType) //3 //输入名称 console.log(hh.nodeName)// Text 文本类型 } </script> <body> <p>测试换行</p> <h1>测试换行</h1> </body> </html>