getElementsByClassName Deluxe Edition
General
JavaScript does not provide a function for obtaining elements by class, only by id, name, and tag name. This snippet will accomplish that, and includes optional arguments with defaults and support for multiple classnames in any order. It works in IE, Firefox, Opera, Safari and IE Mac.
Notes
- Created by: Stuart Colville
- Web Site: http://muffinresearch.co.uk/
- Posted: August 8, 2007
The function has three parameters:
strClassstrTag (optional, defaults to ?*?)objContElm (optional, defaults to document)Examples can be seen here.
Complete instructions can be found on the Muffin Research Labs Web site.
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: classNameDE.js
Head
Paste this code into the HEAD section of your HTML document.


Leave a Response
(0 comments)