规范文件:DOM文本节点 [英] Specification Document: DOM Text Nodes
本文介绍了规范文件:DOM文本节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读文件< head> 元素之前没有文本节点?为什么 DOCTYPE
和< html>
节点之间没有文本节点?错误或功能?
I am reading a document about HTML5. A few lines down from where I linked, a sample DOM tree is displayed for the sample HTML code given. Why is there no text node directly before the <head>
element? Why is there no text node between the DOCTYPE
and <html>
nodes? Error or feature?
推荐答案
功能。主要原因是,鉴于标记
Feature. The main reason is that, given the markup
<!DOCTYPE html>
<html>
<head>
<title>Sample page</title>
...,
有些人希望
document.documentElement.firstChild
返回头
元素。但是,如果包含文本节点,那就是要返回的节点。
to return the head
element. However, if the text node were included, that is the node that would be returned.
(另请注意,之间的新行; / body>
和< / html>
最终在正文
元素中。 )
(Note, also, that the new line between </body>
and </html>
ends up in the body
element.)
这篇关于规范文件:DOM文本节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文