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.
document.nodeType
9
There are 12 node types, represented by integers. As you can see, the document node type is 9. 

The most useful are 
1 (element), 
2 (attribute), and 
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:

document.nodeName
"#document"

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.

document.nodeValue
null

Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents