15.3.1 Documents As Trees of Nodes
The Document object, its Element objects, and the Text objects that represent runs of text in the document are all Node objects. Node defines the following important properties:
The Node that is the parent of this one, or null for nodes like the Document object
that have no parent.
A read-only array-like object (a NodeList) that is a live representation of a Node’s child nodes.
The first and last child nodes of a node, or null if the node has no children. nextSibling, previousSibling
The next and previous sibling node of a node. Two nodes with the same parent are
siblings. Their order reflects the order in which they appear in the document. These
properties connect nodes in a doubly linked list.
15.3 Document Structure and Traversal | 371
The kind of node this is. Document nodes have the value 9. Element nodes have the value 1. Text nodes have the value 3. Comments nodes are 8 and Document-Fragment nodes are 11.
The textual content of a Text or Comment node.
The tag name of an Element, converted to uppercase.
Using these Node properties, the second child node of the first child of the Document can be referred to with expressions like these:
Suppose the document in question is the following:
Then the second child of the first child is theelement. It has a nodeType of 1 and a nodeName of “BODY”.欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/27925.html