Monday, April 16, 2012

DOM: Document Object Model

A web page is referred to as a "document." It is structured like a tree. Each tag forms a node in the tree; nested nodes form branches. Every element in your code contributes to the tree: all the text, all the tags, all the attributes, everything.
This tree is the model that the browser uses to understand your page. It is referred to as the "Document Object Model," or DOM for short.

Javascript can "see" all the branches of the tree. It can talk to and manipulate all the elements in your code. Javascript can move gracefully from node to node, performing the required actions for each node in turn. This is called "traversing the DOM."
The best way to get an idea of what all this means for you is to play with code and see what it does. First we are going to review the basics of the Javascript language, then we're going to get silly.

No comments:

Post a Comment