classlist-multiple-values

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
classlist-multiple-values
101.0.17 years ago7 years agoMinified + gzip package size for classlist-multiple-values in KB

Readme

classlist-multiple-values
!Build Statusci-imgci !BrowserStack Statusbrowserstack-imgbrowserstack
Use multiple values for classList.add and classList.remove methodsclasslist-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ć