Function: document.getElementById('theId') takes a string as a parameter that should match the id of the element you want. Of course, this means that any element you want to access this way needs an id attribute set. This function returns a reference to the object so that you may use it.
Examples:
The code:
<h1 id="mainHeading"> Main Heading</h1>
<script type="text/javascript"> alert('about to change the Main heading to yellow'); document.getElementById('mainHeading').style.color='yellow'; </script>
<button onclick="document.getElementById('mainHeading').style.color='black';"> Click make h1 black again </button>