<a href="index.html" id="homeLink">Home</a>
document.getElementById("homeLink").style.color = "green";
Tip: don't forget to enclose the id argument in single or double-quotes, or JavaScript will be looking for a variable named homeLink in your script (which it probably won't find!)
document.getElementById("HomeLink").style.color = "green"; // Error!
Caveat: by definition ("unique identifier"), a given id should only occur once per HTML doc. If it is used multiple times, the web browser's JavaScript interpreter will typically pick the first one it finds, and ignore the others - but that behavior is not reliably predictable.
if( document.getElementById("homeLink") != null ) // Does it exist?
document.getElementById("homeLink").style.color = "red";
else
alert("There's no element homeLink on this page!");
But because null evaluates to false, you can also use this shortcut to see if an element exists: if( document.getElementById("homeLink") ) // Only true if found
alert("homeLink exists on this page!");
document.getElementById("#homeLink").style.color = "blue"; // WRONG!
$("#homeLink").css("color","blue"); // CORRECT in jQuery :-)