In the code below, I am applying a different background color to all even rows by dynamically assigning the class \"even\" to them using javascript. I am calling the alternamte(
getElementsByTagName() returns an array matching the selector. Hence try
var table = getElementsByTagName('table')[indexnumber];