The document Node

To access the current document use document.

To explore this object, you can once again type document and click on the result in firefox or chrome. In the DOM tab where you can browse all of the properties and methods of the document object.

All nodes (this also includes the document node, text nodes, element nodes, and attribute nodes) have nodeType, nodeName, and nodeValue properties.



There are 12 node types, represented by integers. As you can see, the document node type is 9.

The most useful are

  1. 1 (element),
  2. 2 (attribute),
  3. 3 (text)

Nodes also have names. For HTML tags the node name is the tag name (tagName property). For text nodes, it is #text, and for document nodes:



Nodes can also have node values, for example for text nodes; the value is the actual text. The document node doesn't have a value.


Related Tutorial
Follow Us #
Contents +