JavaScript querySelector() method - ID example
by danielkwood
HTML
<html>
<head>
<title>querySelector() method</title>
</head>
<body>
<p id="myID">This is some text</p>
<p id="myID">This is some more text</p>
</body>
</html>
JavaScript
// get the first element that has the ID "myID" using querySelector("p");
var myPararagraph = document.querySelector("#myID");
// Change the innerHTML content
myPararagraph.innerHTML = "This is some new text";