CHAPTER 10

image

Document Object Model

The Document Object Model or DOM is a programming interface that describes all elements of a web document and how they are related to each other. It is through this interface that JavaScript code can interact with the web document.

DOM Nodes

In the DOM model, the content of the web document is represented in a tree-like structure consisting of nodes. By knowing how these nodes are organized, it becomes possible to change any part of the document dynamically. Consider the following HTML markup.

<p>My paragraph</p>

This markup creates two nodes in the DOM tree: an element node and a text node. Element nodes can have ...

Get JavaScript Quick Syntax Reference 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.