getElementById

Although we can access any node on a web page via the childNode.childNode.childNode it is usually simpler and more reliable to use the getElementById('id') method.

The main problem with the childNode.childNode.childNode approach is that some browsers introduce bogus nodes into their DOM tree.
This can make the actual path to the node difficult to find.

The getElementById('id') method allows us to go directly to the node called id.

The two drawbacks are
- we cannot add an id to a text node
- we must add an ID attribute to every node we wish access or at least to a node closely related to it.

Assume we have a text node within a div whose id atribute is 'fred'.
<div id='fred'>Old text</div>
We can access the text node and change it by using its parent/child relationship with fred.

document.getElementById('fred').firstChild.nodeValue='New Text';