Center align data in a PeopleSoft grid using JavaScript

I had a requirement to center align data in a PeopleSoft grid. Instead of messing with the delivered Style Sheets and creating new ones I simply adding an HTML area to my page and used JavaScript to center it.

getElementsByClassName() returns a HTMLCollection so you need to iterate through the results.

Here is the JavaScript example:

var elements = document.getElementsByClassName("PSLEVEL1GRIDODDROW");
for(var i=0, l=elements.length; i<l; i++)
elements[i].style.textAlign = "center";