节点值nodeValue

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>节点值nodeValuetitle>
    
head>
<body>
    <span>我是节点里面的值span>
    <script>
        var span=document.getElementsByTagName("span")[0];
        var a=span.firstChild;//获取span节点内的第一个子节点
        console.log(a.nodeValue);//获取a节点的值
    script>
body>
html>

你可能感兴趣的:(节点值nodeValue)