The Document Object Model (DOM), Part I: The Object's Properties - www.docjavascript.com
The Document Object Model (DOM), Part I (3)
The Object's Properties
The Document Object Model provides a set of properties that you can use to navigate, access, and update the document tree with. The following table shows the read-only properties:
DOM's Property | Returns | Comments |
firstChild | The first child node. | An [object] . All children are included in childNodes collection. |
lastChild | The last child node. | An [object] . All children are included in childNodes collection. |
nextSibling | The next child of the node's parent. | An [object] . |
nodeName | The HTML Tag. | Examples: P, FONT, UL. |
nodeType | Whether the node is a tag, text, or attribute. | Returns 1 for tag, 2 for attribute, and 3 for text. |
parentNode | A reference to the parent node. | An [object] . |
previousSibling | A reference to the previous child of the node's parent. | An [object] . |
specified | Whether an attribute value is set. | Boolean |
The following table shows the read-write properties:
DOM's Property | Returns | Comments |
data | The value of a text node. | A string. Returns undefined for all other nodes. Can be set as well. |
nodeValue | The value of a text node. | A string. Returns null for all other nodes. Can be set as well. |
And finally, here are the collections defined for the DOM:
DOM's Property | Returns | Comments |
attributes | A collection of the node's attributes. | Access by name. Example:attributes.id . |
childNodes | A collection of the node's children. | Access by index. Example:childNodes[2] . |
Produced by Yehuda Shiran and Tomer Shiran
Created: May 31, 1999
Revised: May 31, 1999
URL: https://www.webreference.com/js/column40/properties.html