<html>
<body>
<h2>Using The id Attribute in JavaScript</h2>
<p>JavaScript can access an element with a specified id by using the getElementById() method:</p>
<h1 id="myHeader">Hello World!</h1>
<button onclick="displayResult()">Change text</button>
<script>
function displayResult() {
document.getElementById("myHeader").innerHTML = "Have a nice day!";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/html/tryit.asp?filename=tryhtml_id_js by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:24:41 GMT -->
</html>