The body element of a document is the first child of the html element
但是当我检查它不是 body
时,它是 head
元素:
document.getElementsByTagName("html")[0].firstElementChild
> <head>...</head>
我是不是误会了什么?因为我不认为 w3.org
可能是错误的。
最佳答案
这句话是指 body
属性返回的内容,而不是 html
元素的内容。
"The body element of a document is the first child of the html element that is either a body element or a frameset element."
这意味着 body
属性将返回常规页面的 body
元素,因为这是匹配其中一种类型的第一个(也是唯一一个)元素。
关于html - html 元素的第一个子元素是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31959043/