getElementsByClassName Deluxe Edition

JavaScript language does not provide us a function for obtaining elements by class, only by id, name, and tag name. This JavaScript snippet will accomplish that, and includes optional arguments with defaults and support for multiple classnames in any order. It works in Internet Explorer, Firefox, Opera, Safari and Mac.

Over 2000+ free Javascript
at Website
Sampled by

View source code for details

The function has three parameters:

string containing the class(es) that you are looking for
strTag (optional, defaults to ‘*’)
An optional tag name to narrow the search to specific tags e.g. ‘a’ for links.
objContElm (optional, defaults to document)
An optional object container to search inside. Again this narrows the scope of the search