DHTML DOM (Document Object Model)

DOM (Document Object Model) is that we have the ability to access each element in a document.

Example

Note:Most DHTML examples require IE 4.0+、Netscape 7+ or Opera 7+!

Element Access
How to access an element and change its style.
Attribute Change
How to access an image element and modify the "src" attribute.
innerHTML
How to access and modify the content of an element.

How to access an element?

Elements must have a defined id attribute and need a script language. 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>

This script can change the color of the header element and generate output.

My header