The HTML DOM allows JavaScript to change the content of HTML elements.
JavaScript can create dynamic HTML content:
Date:
In JavaScript, document.write() can be used to write directly to the HTML output stream:
| Never use document.write() after the document is loaded. It will overwrite the document. |
The easiest way to modify the content of an HTML element is by using the innerHTML property.
To change the content of an HTML element, use this syntax:
This example changes the content of a <p> element:
This example changes the content of an <h1> element:
Example explained:
To change the attribute of an HTML element, use this syntax:
This example changes the src attribute of an <img> element:
Example explained:
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.