Java Reference
In-Depth Information
The Document Object Model
What is the Document Object Model?
The Document Object Model , or DOM for short, represents an HTML document as a net-
work of connected nodes that form a tree-like structure [1] .
Everything on a web page is represented by a node ―HTML tags, the text inside these tags,
even the attributes of a tag are all nodes. The HTML tag is the root node and every other
part of the document is a child node of this.
Take the following piece of HTML as an example:
<p class="warning"> Something has gone <em>very</em>
wrong! </p>
This can be represented as the tree diagram shown in Figure 6.1 .
Figure 6.1. The DOM tree
The DOM is not actually part of JavaScript because it is language agnostic . This means that
it can be used in any programming language, not just JavaScript. It is an Application Pro-
gramming Interface (API) that lets us access and modify different parts of a web page using
the built-in document object.
Search WWH ::




Custom Search