| JavaScript - Node types | | Print | |
Node types
Every node in a document tree has a nodeType property that specifies what type of node it is. Different types of nodes are represented by different subclasses of the Node object. The following nodeType values are relevant to JavaScript programmers working with HTML documents (other values exist for XML documents):
|
nodeType |
Represents |
|---|---|
|
1 |
Element: an HTML tag |
|
2 |
Text: text in a document |
|
8 |
Comment: an HTML comment |
|
9 |
Document: the HTML document |
Use the nodeName property of an Element node to determine the name of the HTML tag it represents. Use the nodeValue property of Text and Comment nodes to obtain the document text or comment text represented by the node. See Element, Text, Comment, and Document in the reference section for details on each of these node types. Also see Node for information on the common properties and methods they all share.
| Users' Comments (0) |
|
No comment posted





