1. 程式人生 > >js改變bootstrap switch的選中與否

js改變bootstrap switch的選中與否

無線開關:<div id="wlan_enable_div" class="make-switch" data-on="success" data-off="warning"><input type="checkbox" id="enable" name="enable" checked></div>

    if(info.WLANConfiguration.Enable=='1')
    {//無線開啟
        $('#wlan_enable_id').bootstrapSwitch('toggleState');
        $('#wlan_enable_id').bootstrapSwitch('setState', true);    
    }else
    {//無線關閉
        $('#wlan_enable_div').bootstrapSwitch('toggleState');
        $('#wlan_enable_div').bootstrapSwitch('setState', false);
    }

具體見官網 http://www.bootcss.com/p/bootstrap-switch/

Toggle State