Usually JavaScript libraries include a getElementsByClassName function. However, if you’re building your own personal library, you may want to include your own version. Robert Nyman has built and amended over the past 2.5 years a function for this very method: The Ultimate getElementsByClassName!

The parameters passed in are the element of origin (e.g., document), the tags to search (e.g., “div” or “*”), and the class name or names that you wish to aggregate.

The last revision was May 2007, but the method is so tiny and has undergone several revs. I have added it to my personal library and it works well. I haven’t tested performance, but it’s gone through so many revs that it must be worthwhile to have lasted this long. I know, to make an assumption that something is good because it has lasted is somewhat flawed logic, but from the JS that I know, it looks clean.

JS gurus, tell me, is it hot or not? Downloadable Ultimate getElementsByClassName.

Popularity: 7% [?]

Share and Enjoy:
  • del.icio.us
  • Digg
  • Reddit
  • TwitThis
  • Google Bookmarks
  • StumbleUpon
  • Facebook
  • E-mail this story to a friend!
  • Print this article!