QP School

Full Version: Select elements by ID in JavaScript
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The HTML part between the <body></body> tags looks like this:

Code:
<!-- Select elements by ID -->

<h1 id="message">JavaScript getElementById() Demo</h1>

The JavaScript part looks like this:

Code:
// Select elements by ID

document.getElementById("message").innerHTML = "Demo";