Bootstrap 开关,switch控件

Address

博客1

取值

$('#switcher').bootstrapSwitch('state'); // true || false
$('#switcher').bootstrapSwitch('toggleState');
$('#switcher').bootstrapSwitch('setState', false); // true || false

html

<input name="status" type="checkbox" data-size="small">  

js初始化

$('[name="status"]').bootstrapSwitch({  
        onText:"启动",  
        offText:"停止",  
        onColor:"success",  
        offColor:"info",  
        size:"small",  
        onSwitchChange:function(event,state){  
            if(state==true){  
                $(this).val("1");  
            }else{  
                $(this).val("2");  
            }  
        }  
    })