Properties of Node Object
The Node object represents a single node in the document tree.
- nodeName
- nodeValue
- nodeType
- textContent
- parentNode
- childNodes
- firstChild
- lastChild
- previousSibling
- nextSibling
nodeName
The nodeName read-only property returns the name of the current node as a string.
- CDATASection “#cdata-section”
- Comment “#comment”
- Document “#document”
- DocumentFragment “#document-fragment”
- DocumentType The value of DocumentType.name
- Element The value of Element.tagName
- Entity The entity name
- EntityReference The name of entity reference
- Notation The notation name
- ProcessingInstruction The value of ProcessingInstruction.target
- Text “#text”
nodeValue
The nodeValue property returns or sets the value of the current node.
- CDATASection content of the CDATA Section
- Comment content of the comment
- Document null
- DocumentFragment null
- DocumentType null
- Element null
- NamedNodeMap null
- EntityReference null
- Notation null
- ProcessingInstruction entire content excluding the target
- Text content of the text node
nodeType
The read-only Node.nodeType property represents the type of the node.
Constant | Node Type | Description |
Node.ELEMENT_NODE | 1 | An element such as <h1> or <div> |
Node.TEXT_NODE | 3 | The actual Text of Element or Attribute ex: – “Hello” |
Node.PROCESSING_INSTRUCTION_NODE | 7 | An instruction to a parser on aspect of the document <?xml version=“1.0”?> |
Node.COMMENT_NODE | 8 | A comment such as < – – Something – – > |
Node.DOCUMENT_NODE | 9 | A Document Node |
Node.DOCUMENT_TYPE_NODE | 10 | A doctype statement <!DOCTYPE html> |
Node.DOCUMENT_FRAGMENT_NODE | 11 | A document fragment, which represents a lightweight structure to hold a collection of DOM nodes for manipulation or insertion. |