14.08.2016 Views

Beginning JavaScript with DOM Scripting and Ajax, 2nd Edition

Create successful ePaper yourself

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

Chapter 4 ■ HTML <strong>and</strong> <strong>JavaScript</strong><br />

Figure 4-2. The <strong>DOM</strong> representation of a document illustrated in the Mozilla <strong>DOM</strong> Inspector<br />

■ ■Tip You can access similar tools in Chrome, Safari, Opera, <strong>and</strong> Internet Explorer. Not only can you see how the<br />

document is represented, you can also edit the code <strong>and</strong> see the results directly in the browser. In the appendix, I’ll cover<br />

validation <strong>and</strong> debugging.<br />

■ ■Note Notice all the #text nodes between the elements? This is not text I added to the document, but the line breaks<br />

I added at the end of each line. Some browsers see those as text nodes, while others don’t—which can be very annoying<br />

when you try to access elements in the document via <strong>JavaScript</strong> later on.<br />

Figure 4-3 shows another way you can visualize the document tree.<br />

72<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!