HOME

DHTML Tutorial
DHTML HOME
DHTML Intro
DHTML CSS
DHTML DOM
DHTML Events

DHTML Examples
DHTML Examples

DHTML DOM
DOM window
DOM navigator
DOM event
DOM collection
DOM document
DOM form
DOM input
DOM select
DOM option
DOM textarea
DOM table
DOM tablerow
DOM tablecell
DOM anchor
DOM image
DOM frameset
DOM frame
DOM iframe

DOM Examples
DOM Examples
Proposal Kit
Please visit our sponsors !

DHTML Document Object Model

previous next

The Document Object Model gives us access to every element in a document.


Examples

Note: Most of the DHTML examples require IE 4.0 or higher.

Element access
How to access an element and change the style.

Attribute change
How to access an image element and change the "src" attribute.

innertext access
How to access and change the inner text 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">
header.style.color="red"
</script>
</body>
</html>

The script changes the color of the header element, and produces this output.

My header



The DHTML Document Object Model

Object   Description
window methods
properties
The window object is the top level object in the DHTML DOM. It contains information about the window and the frames
document methods
properties
collections
The document object represents the HTML document, and is used to access the HTML elements inside the document
navigator properties The navigator object contains information about the user's browser
event properties
collections
The event object contains information about events that occurs


previous next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

ASPHits
Active Server Pages Resource Web Site


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search