JavaScript is typically used to manipulate HTML elements.
To access an HTML element from JavaScript, you can use the document.getElementById(id) method.
Use the "id" attribute to identify the HTML element:
Access the HTML element with the specified id, and change its content:
The JavaScript is executed by the web browser. In this case, the browser will access the HTML element with id="demo", and replace its content (innerHTML) with "My First JavaScript".
The example below writes a <p> element directly into the HTML document output:
Use document.write() only to write directly into the document output.
If you execute document.write after the document has finished loading, the entire HTML page will be overwritten:
| Microsoft supports JavaScript for creating Windows 8 apps. JavaScript is definitely the future for both the Internet and Windows. |
Your message has been sent to W3Schools.