<!DOCTYPE html> <html> <body> <h1>Element 对象</h1> <h2>nodeName、nodetype 以及 nodeValue 属性</h2> <div id="myDIV">This is "myDIV".</div> <p>“myDIV” 的第一个子节点的节点名称、类型和值是:</p> <p id="demo"></p> <script> const x = document.getElementById("myDIV").firstChild; let text = ""; text += "Name: " + x.nodeName + "<br>"; text += "Value: " + x.nodeValue + "<br>"; text += "Type: " + x.nodeType; document.getElementById("demo").innerHTML = text; </script> </body> </html>