npm install jquery-btnswitch
you must be using at least jQuery 2.0
Default: Button
Default: On
Default: Off
Default: true
Default: false
Default: null
Default: null
Default: false
Default: false
Default: Are you sure?
Default: false
$('#btnSwitch').btnSwitch();
$('#btnSwitch').btnSwitch({
ConfirmChanges: true,
ConfirmText: 'You really want to do that?',
OnCallback: function(val) {
alert('system is now on');
},
OffCallback: function (val) {
alert('system is now off');
}
});
$('#btnSwitch').btnSwitch({
OnValue: 'On',
OnCallback: function(val) {
alert('you selected ' + val);
},
OffValue: 'Off',
OffCallback: function (val) {
alert('you selected ' + val);
}
});
You can change the look of the switch by selecting one of the possible themes below:
$('#btnSwitch').btnSwitch({
Theme: 'Light'
});
$('#btnSwitch').btnSwitch({
Theme: 'Swipe'
});
$('#btnSwitch').btnSwitch({
Theme: 'iOS'
});
$('#btnSwitch').btnSwitch({
Theme: 'Android'
});