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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.