bootstrap开关控件

1、引入
<link rel="stylesheet" href="bootstrap-switch/css/bootstrap-switch.css" />
<script type="application/javascript" src="js/jquery-1.10.2.min.js">script>
<script type="application/javascript" src="bootstrap-switch/js/bootstrap-switch.js">script>
2、用法一
<input type="checkbox" name="box" id="c">
<script>
$(function(){
   $('#c').bootstrapSwitch({ 
        onText:"启动", 
        offText:"停止", 
        onColor:"success", 
        offColor:"info", 
        size:"small", 
        onSwitchChange:function(event,state){ 
            if(state==true){ 
                $(this).val("1"); 
            }else{ 
                $(this).val("2"); 
            } 
        } 
    }) 
});
script>
3、用法二
<div class="switch">
  <input type="checkbox" name="close" data-on-text="是" data-off-text="否"/>
div>
<script type="text/javascript">
$(function(){
    $("input[name='close']").bootstrapSwitch();
});
script>

你可能感兴趣的:(bootstrap)