Hour 12. Scripting the DOM

What You’ll Learn in This Hour

• How to create new elements

• Ways to add, edit, and remove child nodes

• Dynamically loading JavaScript files

• Changing element attributes

Tip

When you amend the DOM using the methods described in this hour, you change the way a page appears in the browser. Bear in mind, though, that you’re not changing the document itself. If you ask your browser to display the source code of the page, you won’t see any changes there.

That’s because the browser is actually displaying the current DOM representation of the document. Change that, and you change what appears onscreen.

In the previous hour, you learned how to navigate the DOM tree to select specific nodes (or collections of nodes) and ...

Get Sams Teach Yourself JavaScript™ in 24 Hours, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.