1.0.1 • Published 9 years ago
classlist-multiple-values v1.0.1
classlist-multiple-values
Use multiple values for classList.add and classList.remove methods.
Install
npm install classlist-multiple-values --saveUsage
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ć