|
DHTML - HTML DOM
What is the HTML DOM?
The HTML DOM is:
- A Document Object Model for HTML
- A standard programming interface for HTML
- Platform- and language-independent
- A W3C standard
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 HTML h1 element:
Example
<html>
<body>
<h1 id="header">Old Header</h1>
<script type="text/javascript">
document.getElementById("header").innerHTML="New Header";
</script>
</body>
</html>
|
|
Example explained:
- The HTML document contains a header with id="header"
- The DOM is used to get the element with id="header"
- A JavaScript is used to change the HTML content (innerHTML)
Change an HTML Attribute
The following example changes the src attibute of an HTML img element:
Example
<html>
<body>
<img id="image" src="smiley.gif">
<script type="text/javascript">
document.getElementById("image").src="landscape.jpg";
</script>
</body>
</html>
|
|
Example explained:
- The HTML document loads with an image with id="image"
- The DOM is used to get the element with id="image"
- A JavaScript changes the src attribute from smiley.gif to landscape.jpg
HTML DOM Tutorial
To learn more about the HTML DOM, find the complete HTML DOM tutorial on our Home Page.

Whether you're new to XML or already an advanced user,
the user-friendly views and powerful entry helpers,
wizards, and debuggers in XMLSpy are designed to meet your XML
and Web development needs from start to finish.
- XML editor
- Graphical XML Schema / DTD editors
- XSLT 1.0/2.0 editor, debugger, profiler
- XQuery editor, debugger, profiler
- XBRL validator & taxonomy editor
- Support for Office Open XML (OOXML)
- Graphical WSDL editor & SOAP debugger
- Java, C#, C++ code generation
- And much more!
Download a free trial today!
|
|
|
|