A leightweight (0.3kB) extension to the Element prototype to allow checking, adding, removing and toggling classes.
Want to see pretty graphs? Log in now!
npm install cssclass
|2||downloads in the last week|
|8||downloads in the last month|
|Last Published By|
|Version||1.1.0 last updated 6 months ago|
|Keywords||css, class, classes, cssclass, classlist, ender|
The usage is easy. Include the script file and just use the functions (they can be chained). You can also add, remove, toggle or check for multiple classes by just adding a space between them.
var test = document.getElementById('test'); if (test.hasClass('active')) test.addClass('glow'); test.removeClass('active glow').toggleClass('golden');
CSSClass now uses the classList interface if available.
If you encounter an error or have a feature suggestion please open a new issue on GitHub (https://github.com/EarMaster/CSSClass/).
As IE7 and below don't allow access to the Element prototype it will not work on these browsers.