classlist-multiple-values

1.0.1 • Public • Published

classlist-multiple-values

Build Status BrowserStack Status

Use multiple values for classList.add and classList.remove methods.

Install

npm install classlist-multiple-values --save

Usage

const multipleValues = require('classlist-multiple-values');
const element = document.querySelector('.jackie');
 
const cl = multipleValues(element.classList);
 
cl.add('henry winnie');
cl.add(['scooter', 'emma']);
 
cl.remove('henry winnie');
cl.remove(['scooter', 'emma']);

API

multipleValues(classList)

Returns: Object

Returns improved add and remove methods.

classList

Type: Object|DOMTokenList

Object or DOMTokenList which must contain add and remove methods.

multipleValues.add(values)

values

Type: String[]|String

Array of strings or space-separated string of class values to add to the element.

multipleValues.remove(values)

values

Type: String[]|String

Array of strings or space-separated string of class values to remove from the element.

Test

For local automated tests, run npm run test:automated:local.

Browser support

Tested in IE9+ and all modern browsers.

License

MIT © Ivan Nikolić

Package Sidebar

Install

npm i classlist-multiple-values

Weekly Downloads

1,123

Version

1.0.1

License

MIT

Last publish

Collaborators

  • niksy