Java Reference
In-Depth Information
Note Strictly speaking, the align attribute is deprecated, but you used it
because it works and because it has one of the most easily demonstrable
visual effects on a web page.
the Node Object
You now have your element or elements from the web page, but what happens if you want to move
through your page systematically, from element to element or from attribute to attribute? This is
where you need to step back to a lower level. To move among elements, attributes, and text, you
have to move among nodes in your tree structure. It doesn't matter what is contained within the
node, or rather, what sort of node it is. This is why you need to go back to one of the objects of the
core DOM specification. Your whole tree structure is made up of these baseā€level Node objects.
The Node Object: Navigating the DOM
The following table lists some common properties of the Node object that provide information about
the node, whether it is an element, attribute, or text, and enable you to move from one node to another.
properties of the node objeCt
desCription of propertY
Returns the first child node of an element
firstChild
Returns the last child node of an element
lastChild
Returns the previous child node of an element at the same
level as the current child node
previousSibling
Returns the next child node of an element at the same level
as the current child node
nextSibling
Returns the root node of the document that contains the
node (note this is not available in IE 5 or 5.5)
ownerDocument
Returns the element that contains the current node in the
tree structure
parentNode
Returns the name of the node
nodeName
Returns the type of the node as a number
nodeType
Gets or sets the value of the node in plaintext format
nodeValue
Let's take a quick look at how some of these properties work. Consider this familiar example:
<!DOCTYPE html>
<html lang="en">
<head>
 
Search WWH ::




Custom Search