子节点childNodes

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>子节点childNodestitle>
    
head>
<body>
    <div>
        <p><span>span>p>文本div>
    <script>
        var div=document.getElementsByTagName("div")[0];
        console.log(div.childNodes);//[text,p, text],第一个text是空白节点
        console.log(div.firstChild);//

console.log(div.lastChild);//"文本" script> body> html>

你可能感兴趣的:(子节点childNodes)