📦 Add, remove, list and check style classes of an element, or a group of them, in your DOM.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
.babelrc
.gitignore
README.md
gulpfile.js
index.js
package.json

README.md

classes-manager

Add, remove, list or check style classes of an element, or group of them, in your DOM. Implemented with ES2015 and only native js. For a faster performance I recommend passing the element, or elements, via native .querySelector(), or .querySelectorAll(), it is way faster than other libraries like jQuery.

Install

$ npm install classes-manager

Usage

import classes from 'classes-manager'

API

.add(el, class)

Add a class to the element/s.

.remove(el, class)

Remove a class from the element/s.

.has(el, class)

Check if a class is present in the element/s. It returns values of T/F.

.classes(el)

Return an array of classes present in the element.

classes(el)
// => ['active', 'nav']

Example

import classes from 'classes-manager'

classes.add(document.querySelector('.existingClass'),'classToAdd')