From http://www.w3schools.com (Copyright Refsnes Data)

DHTML - HTML DOM

« Previous Next Chapter »

What is the HTML DOM?

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.


Change an HTML Element

The following example changes the content of an h1 element:

Example

<html>
<body>

<h1 id="header">Old Header</h1>

<script type="text/javascript">
document.getElementById("header").innerHTML="New Header";
</script>

</body>
</html>

Try it yourself »

Example explained:


Change an HTML Attribute

The following example changes the src attibute of an img element:

Example

<html>
<body>

<img id="image" src="smiley.gif">

<script type="text/javascript">
document.getElementById("image").src="landscape.jpg";
</script>

</body>
</html>

Try it yourself »

Example explained:


HTML DOM Tutorial

To learn more about the HTML DOM, please read our complete HTML DOM tutorial.


« Previous Next Chapter »

From http://www.w3schools.com (Copyright Refsnes Data)