node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



CSSClass is a JavaScript microframework which adds the functions .hasClass, .addClass, .removeClass and .toggleClass to the Element prototype.

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.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 (

Flattr this

As IE7 and below don't allow access to the Element prototype it will not work on these browsers.