Cover by Marijn Haverbeke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 10. The Document Object Model

In Chapter 9 we saw JavaScript objects that represented the form and input tags from an HTML document. Such objects are part of a structure called the Document Object Model (DOM). Every tag in the document is represented by an object in this model and can be looked up and interacted with.

DOM Elements

HTML documents have a hierarchical structure. Each element (tag) except the top <html> element is contained in another element, called its parent. This element can in turn contain child elements. You can visualize this as a kind of family tree. If we have a simple document like this:

<html> <head> <title>Alchemy for beginners</title> <script type="text/javascript" src="js/base.js"></script> </head> <body> <h1>Chapter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required