From http://www.w3schools.com (Copyright Refsnes Data)
The DOM presents HTML as a tree-structure (a node tree), with elements, attributes, and text:
innerHTML
How to access and change the innerHTML of an element.
Attribute change
How to access an image element and change the "src" attribute.
The HTML DOM is:
The HTML DOM defines the objects and properties of all HTML elements, and the methods (interface) to access them.
In other words:
The HTML DOM is a standard for how to get, change, add, or delete HTML elements.
The HTML DOM can be used to change the content of an HTML element:
<html> <body> <h1 id="header">Old Header</h1> <script type="text/javascript"> document.getElementById("header").innerHTML="New Header"; </script> </body> </html> |
HTML output:
New Header |
Example explained:
The HTML DOM can be used to change the attribute of an HTML element:
<html> <body> <img id="image" src="smiley.gif"> <script type="text/javascript"> document.getElementById("image").src="landscape.jpg"; </script> </body> </html> |
HTML output:
Example explained:
If you want to study more about the HTML DOM, find the complete HTML DOM tutorial on our Home Page.
From http://www.w3schools.com (Copyright Refsnes Data)