democracyos-get-by-class
v0.0.1
Published
A cross-browser implementation of getElementsByClass
Downloads
27
Readme
getByClass
A cross-browser implementation of getElementsByClass. Heavily based on Dustin Diaz's function: http://dustindiaz.com/getelementsbyclass.
Uses default getElementsByClassName
if it's available.
Component
Built to be used with the Component package manager. Read more here:
Installation
$ component install javve/get-by-class
Example
var getByClass = require('get-by-class');
var menu = document.getElementById('menu');
// Returns set of items
var activeItem = getByClass(menu, 'active');
// Returns single item
var activeItem = getByClass(menu, 'active', true);
API
getByClass(container, className, single)
Find all elements with class className
inside container
.
Use single = true
to increase performance in older browsers
when only one element is needed.
License
MIT