What is DOM?
The DOM or Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page.
According to the DOM, everything in an HTML document is a node.
The DOM says:
The programming interface to the DOM is defined by a set standard properties and methods.
Properties are often referred to as something that is (i.e. nodename is “p”).
Methods are often referred to as something that is done (i.e. delete “p”).
Accessing Nodes
You can access a node in three ways:
1. By using the getElementById() method: The getElementById() method returns the element with the specified ID:
for example: document.getElementById(“intro”).
2. By using the getElementsByTagName() method: getElementsByTagName() returns all elements with a specified tag name:
for Example: document.getElementsByTagName(“p”);
3. By navigating the node tree, using the node relationships:
Node Properties
In the HTML Document Object Model (DOM), each node is an object.
Objects have methods (functions) and properties (information about the object), that can be accessed and manipulated by JavaScript.
Three important HTML DOM node properties are:
-
nodeName
-
nodeValue
-
nodeType
Resources: http://www.w3.org/DOM/