Skip to content

javve/get-by-class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web component logo

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

About

A cross-browser implementation of getElementsByClass.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •