运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Element Object</h1> <h2>The firstChild Property</h2> <div id="myDIV"> <p>A paragraph (Second child)</p> <p>A paragraph (Fourth child)</p> </div> <p>The node name of "myDiv"s first child is:</p> <p id="demo"></p> <p>Whitespace between elements is considered text nodes.</p> <p>The first, third and fifth child of "myDIV" is a #text node.</p> <script> let text = document.getElementById("myDIV").firstChild.nodeName; document.getElementById("demo").innerHTML = text; </script> </body> </html>