🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

The stateButton jQuery plugin creates a customizable multi-state toggle button which allows the user to switch between states on click.

Toggle-Button

Documentation

jquery.stateButton

jQuery State Button is a plugin that turns a button into a multi-state switch. Here is a simple demo.

Usage

$('#toggle').stateButton({   values: [ "expanded", "collapsed" ],   current: "collapsed",   text: {     "expanded" : "<i class='fa fa-minus-circle'></i> Collapse",     "collapsed": "<i class='fa fa-plus-circle'></i> Expand"   },   tooltip: {     "expanded" : "Collapse all",     "collapsed": "Expand all"   },   styleClass: {     "expanded" : "btn-expanded",     "collapsed": "btn-collapsed"   },   inlineStyle: {     "expanded": {       "color": "red"     },     "collapsed": {       "color": "green"     }   },   clickCallback: function(newState, oldState) {     console.log('button', this);     console.log('old state', oldState);     console.log('new state', newState);   } });

The component can be configured through the markup API using the HTML data-state-* attributes. The buttons that have data-toggle="state" will be automatically initialized:

<button id="toggle"         data-toggle="state"         data-state-current="collapsed"         data-state-values="collapsed,expanded"         data-state-text-expanded="<i class='fa fa-minus-circle'></i> Collapse"         data-state-text-collapsed="<i class='fa fa-plus-circle'></i> Expand"         data-state-tooltip-expanded="Collapse all"         data-state-tooltip-collapsed="Expand all"></button>

You May Also Like