Skip to Main Content
Coding with JavaScript For Dummies
book

Coding with JavaScript For Dummies

by Chris Minnick, Eva Holland
May 2015
Beginner content levelBeginner
360 pages
6h 39m
English
For Dummies
Content preview from Coding with JavaScript For Dummies

Chapter 10

Manipulating Documents with the DOM

In This Chapter

arrow Getting to know the DOM (Document Object Model)

arrow Working with nodes

arrow Moving around the tree

arrow Selecting elements

No object is mysterious. The mystery is your eye.

— Elisabeth Bowen

Understanding the DOM is key to being able to manipulate the text or HTML in a web page. Using the DOM, you can create animations, update data without refreshing web pages, move objects around in a browser, and much more!

Understanding the DOM

The Document Object Model is the interface for JavaScript to talk to and work with HTML documents inside of browser windows. The DOM can be visualized as an inverted tree, with each part of the HTML document branching off of its containing part.

Listing 10-1 is the markup for a web page. The DOM representation is shown in Figure 10-1.

image

Figure 10-1: A representation of the Document Object Model for Listing 10-1.

Listing 10-1: An HTML Document

<html> <head>  <title>Bob's Appliances</title> ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

HTML5 Programming with JavaScript For Dummies

HTML5 Programming with JavaScript For Dummies

John Paul Mueller
JavaScript For Kids For Dummies

JavaScript For Kids For Dummies

Chris Minnick, Eva Holland

Publisher Resources

ISBN: 9781119056072Purchase book