运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>The Element Object</h1> <h2>The firstChild Property</h2> <p>Example list:</p> <ul id="myList"><li>Coffee</li><li>Tea</li></ul> <p>The HTML content of the list's first child node is:</p> <p id="demo"></p> <p>Whitespace between elements is considered text nodes. If there is a whitespace before the first "li" element, the result will be "undefined".</p> <script> let text = document.getElementById("myList").firstChild.innerHTML; document.getElementById("demo").innerHTML = text; </script> </body> </html>