A jQuery plugin to easily add, remove and toggle classes at once.
This plugin uses the UMD pattern and can be used in different environmens (AMD, CommonJS, browser globals).
bower install jquery-classes
- Production version (~450 bytes minified & gzipped)
- Development version
In your web page:
<script src="jquery.js"></script>
<script src="dist/jquery-classes.min.js"></script>
<script>
jQuery(function($) {
$(...).classes('...');
});
</script>
$(...).classes(); // => gets all the classes for the first element in the collection
$(...).classes('+someclass'); // => adds a class to all elements in the collection
$(...).classes('-someclass'); // => removes a class from all elements in the collection
$(...).classes('~someclass'); // => toggles a class for all elements in the collection
$(...).classes('+state-open +state-active ~visible -list-item +list-item-active');
Any feedback or pull requests are welcome.
See CONTRIBUTING.md
file for more information.
MIT © 2014 Radko Dinev
See LICENSE
file.