
Examples
innerHTMLHow to access and change the innerHTML of an element.
How to access an image element and change the "src" attribute.
What is the HTML DOM?
The HTML DOM is:- A standard object model for HTML
- A standard programming interface for HTML
- Platform- and language-independent
- A W3C standard
In other words:
The HTML DOM is a standard for how to get, change, add, or delete HTML elements.
Using the HTML DOM to Change an HTML Element
The HTML DOM can be used to change the content of an HTML element:<html> |
New Header |
- 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)
Using the HTML DOM to Change an HTML Attribute
The HTML DOM can be used to change the attribute of an HTML element:<html> |
![]() |
- 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