Cross-browser element class manipulation
JavaScript
Switch branches/tags
Pull request Compare This branch is 6 commits ahead, 34 commits behind component:master.
Latest commit e6bdd52 Apr 9, 2016 @TehShrike TehShrike Republished as 1.0.0
Permalink
Failed to load latest commit information.
.gitignore refactor Sep 15, 2013
.npmignore
README.md refactor Sep 15, 2013
index.js
package.json
test.js

README.md

dom-classes

Cross-browser element class manipulation, utilizing the native .classList when possible. This is not designed to be a .classList polyfill.

Install

$ npm install dom-classes

Usage

classes = require('dom-classes')

classes(el)
// => ['foo', 'bar']

API

classes(el)

Return an array of classes

classes(el)
// => ['foo', 'bar']

.add(el, class)

Add class

.remove(el, class)

Remove class name or all classes matching the given regular expression.

.toggle(el, class)

Toggle class.

.has(el, class)

Check if class is present.

.contains(el, class)

Check if class is present.