元素子节点children

DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>元素子节点childrentitle>
    
head>
<body>
    <p>p>
    <script>
        var a=document.body.childNodes;//获取所有子节点
        var b=document.body.children;//获取元素子节点
        console.log(a);//[text,p,script,text]
        console.log(NodeList.length)
        console.log(b);//[p,script]
        console.log(document.body.childElementCount);//2
    script>
body>
html>

你可能感兴趣的:(元素子节点children)