DHTML - HTML Document Object Model (DOM)The DOM presents HTML as a tree-structure (a node tree), with elements, attributes, and text: ExamplesinnerHTML Attribute change 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. Using the HTML DOM to Change an HTML ElementThe HTML DOM can be used to change the content of an HTML element:
HTML output:
Example explained:
Using the HTML DOM to Change an HTML AttributeThe HTML DOM can be used to change the attribute of an HTML element:
HTML output:
Example explained:
More About the HTML DOMIf you want to study more about the HTML DOM, find the complete HTML DOM tutorial on our Home Page. |
DHTML Event HandlersHTML events can trigger actions in the browser.
onclick onmousedown and onmouseup onload Event handlersAn event handler allows you to execute code when an event occurs. Events are generated by the browser when the user clicks an element, when the page loads, when a form is submitted, etc. In the following example, the h1 heading changes when a user clicks on it:
You can also add a script in the head section of the page and then call the function from the event handler: More About HTML EventsFor all HTML events, look at our complete HTML DOM Event Object Reference. |