dom-classes

Cross-browser element class manipulation

npm install dom-classes
1 downloads in the last day
10 downloads in the last week
105 downloads in the last month

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.

npm loves you