That would overwrite any classnames already on the elements.
To keep the existing classes and add a new on simply add a space and the new class name to the end of the existing class list.
You should also use a regular expression to test for the class name with a boundary on either side in order to allow for it not being the only class in the class attribute.
See
http://javascriptexample.net/dom04.php for the sort of loop you'd have using getElementsByClassName that also adds that method for browsers that don't already have it.