Head First Ajax Code: Chapter 7, Manipulating the DOM

Chapter 7 Opening Image

Sometimes you just need a little mind DOM control.

Head First Ajax

It's great to know that web browsers turn your XHTML into DOM trees. And you can do a lot by moving around within those trees. But real power is taking control of a DOM tree and making the tree look like you want it to. Sometimes what you really need is to add a new element and some text, or to remove an element, like an , from a page altogether. You can do all of that and more with the DOM, and along the way, banish that troublesome innerHTML property altogether. The result? Code that can do more to a page, without having to mix presentation and structure in with your JavaScript.

Download Code

Webville Puzzles Files (zip)

Webville Puzzles (Completed Game) (zip)

View the Finished Site

Webville Puzzles (opens a new window)