11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table 10-2: DOM Node Properties<br />

DOM Node<br />

Properties<br />

Description<br />

>nodeName Contains the name of the node<br />

>nodeValue Contains the value within the node; generally only applicable to<br />

text nodes<br />

>nodeType Holds a number corresponding to the type of node, as given in<br />

Table 10-1<br />

>parentNode A reference to the parent node of the current object, if one<br />

exists<br />

>childNodes Access to list of child nodes<br />

>firstChild <strong>Reference</strong> to the first child node of the element, if one exists<br />

>lastChild Points to the last child node of the element, if one exists<br />

>previousSibling <strong>Reference</strong> to the previous sibling of the node; for example, if its<br />

parent node has multiple children<br />

>nextSibling <strong>Reference</strong> to the next sibling of the node; for example, if its<br />

parent node has multiple children<br />

>attributes <strong>The</strong> list of the attributes for the element<br />

>ownerDocument Points to the HTML Document object in which the element is<br />

contained<br />

Note DOM HTMLElement objects also have a property tagName that is effectively the same<br />

as the Node object property nodeName.<br />

Given the new properties, we can ―walk‖ the given example quite easily. <strong>The</strong> following is a<br />

simple demonstration of walking a known tree structure.<br />

<br />

<br />

<br />

DOM Walk Test<br />

<br />

<br />

<br />

A paragraph of text is just<br />

an example

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!