Use multiple values for classList.add
and classList.remove
methods.
npm install classlist-multiple-values --save
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']);
Returns: Object
Returns improved add
and remove
methods.
Type: Object|DOMTokenList
Object
or DOMTokenList
which must contain add
and remove
methods.
Type: String[]|String
Array of strings or space-separated string of class values to add to the element.
Type: String[]|String
Array of strings or space-separated string of class values to remove from the element.
For local automated tests, run npm run test:automated:local
.
Tested in IE9+ and all modern browsers.
MIT © Ivan Nikolić