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.

Notice that the tree structure follows the structured nature of the (X)HTML. <strong>The</strong> <br />

element contains the and . <strong>The</strong> contains the , and the<br />

contains the various block elements like paragraphs (), headings (),<br />

and lists (). Each element may in turn contain more elements or textual fragments. As<br />

you can see, each of the items (or, more appropriately, nodes) in the tree correspond to the<br />

various types of objects allowed in an HTML or XML document. <strong>The</strong>re are 12 types of nodes<br />

defined by the DOM; however, many of these are useful only within XML documents. We‘ll<br />

discuss <strong>JavaScript</strong> and XML in Chapter 20, so for now the node types we are concerned with<br />

are primarily related to HTML and are presented in Table 10-1.<br />

Table 10-1: DOM Nodes Related to HTML Documents<br />

Node<br />

Type<br />

Number<br />

Type Description Example<br />

1 Element An (X)HTML<br />

or XML<br />

element<br />

2 Attribute An attribute<br />

for an HTML<br />

or XML<br />

element<br />

3 Text A fragment<br />

of text that<br />

would be<br />

enclosed by<br />

an HTML or<br />

XML<br />

element<br />

8 Comment An HTML<br />

comment<br />

9 Document <strong>The</strong> root<br />

document<br />

object,<br />

namely the<br />

top element<br />

in the parse<br />

tree<br />

10 DocumentType A document<br />

type<br />

definition<br />

…<br />

align="center"<br />

This is a text fragment!<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!