DHTML Document Object Model
The Document Object Model gives us access to every element in a document.
Note: Most of the DHTML examples require IE 4.0+, Netscape 7+, or Opera 7+!
How to access an element?
The element must have an id attribute defined and a scripting language is needed. JavaScript is the most browser compatible scripting language, so we use JavaScript.
<html> <body> <h1 id="header">My header</h1> <script type="text/javascript"> document.getElementById('header').style.color="red" </script> </body> </html> |
The script changes the color of the header element, and produces this output.