JSPM

cssclass

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 46
  • Score
    100M100P100Q58029F

A leightweight (0.3kB) extension to the Element prototype to allow checking, adding, removing and toggling classes.

Package Exports

  • cssclass

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cssclass) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CSSClass

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.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/).

Flattr this

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