1. 程式人生 > >Bootstrap switch.js 開關外掛 api

Bootstrap switch.js 開關外掛 api

       onText:"照明",  
       offText:"熄滅",  
       onColor:"success",  
       offColor:"info",  
       size:"small",  
       onSwitchChange:function(event,state){  
           if(state==true){  
               $(this).val("1");  
               console.log("開啟");
           }else{  
               $(this).val("2");
               console.log("關閉");
           }  
       }  
   });       $("#close").click(function(){
         $('[name="status"]').bootstrapSwitch('state', false); // 關閉按鈕
       });       $("#open").click(function(){         $('[name="status"]').bootstrapSwitch('state', true); // 開啟按鈕       });