Checked by default
Unchecked by default
Disabled by default
With a label
With some actions
With custom labels and callbacks
With custom options
Show code
$(function(){
/* Simple ones */
$(".common:checkbox").switchbutton();
/* Switch 5: with check/enable actions */
$("#switch5").switchbutton();
$("#uncheck5").click(function(){
$("#switch5").prop("checked", false).change();
});
$("#check5").click(function(){
$("#switch5").prop("checked", true).change();
});
$("#disable5").click(function(){
$("#switch5").switchbutton("disable");
});
$("#enable5").click(function(){
$("#switch5").switchbutton("enable");
});
/* Switch 6: with custom labels and callbacks */
$("#switch6")
.switchbutton({
checkedLabel: 'YES',
uncheckedLabel: 'NO'
})
.change(function(){
alert("Switch 6 changed to " + ($(this).prop("checked") ? "checked" : "unchecked"));
});
/* Switch 7: with custom options */
$("#switch7").switchbutton({
classes: 'ui-switchbutton-thin',
labels: false
});
});