<html>
<body>
<h3>A demonstration of how to access a H2 element</h3>
<h2 id="myHeading">This is a h2 element.</h2>
<p>Click the button to set the color of the h2 element to red.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.getElementById("myHeading");
x.style.color = "red";
}
</script>
</body>
</html>