Prereqs: this tutorial assumes that you are familiar with Arrays and their "length" property.
var theLinks = document.getElementsByTagName("a");
Careful: the word "element" is plural in the method name - getElementsByTagName().
var theLinks = document.getElementsByTagName("a");
if( theLinks.length == 0 ) // Check number of elements returned...
alert("This page contains no links!");
else
alert("There are " + theLinks.length + " links on this page.");
theLinks[0].style.color = "red"; // zero = first array element
theLinks[1].style.color = "orange"; // 1 = second array element
Knowing that "length-1" is the index of an array's last element, let's make our last link green: theLinks[ theLinks.length-1 ].style.color = "green";
var theLinks = document.getElementsByTagName("a");
for( var i=0, j=theLinks.length; i<j; ++i )
theLinks[i].title = "Link # " + (i+1);
// i must start at zero, but humans start counting at 1, thus "i+1"
document.getElementsByTagName("a")[0].style.color = "red";
var allTags = document.getElementsByTagName("*");
var sideLinks = document.getElementById("sn").getElementsByTagName("a");
// ⇑ Defines the parent of the elements we want
$("a").css("color","red"); // makes all links red
In fact, you can pass an element from the getElementsByTagName() collection to jQuery: var theLinks = document.getElementsByTagName("a");
$( theLinks[0] ).css("color","green"); // make first link green