DHTML Document Object Model
The Document Object Model gives us access
to every element in a
document.
Examples
Note: Most of the DHTML examples require IE 4.0+, Netscape 7+, or Opera 7+!
Element access
How to access an element and change the style.
Attribute change
How to access an image element and change the "src" attribute.
innerHTML
How to access and change the innerHTML of an element.
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.
Learn XML with <oXygen/> XML Editor - Free Trial!
 |
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|