bootstrap switch是一个按钮开关,点击时获取其状态可通过以下代码:

 <input id="email_switch_state" type="checkbox">
 $('#email_switch_state').on({
         'switchChange.bootstrapSwitch': function(event, state) {
             if (state == true)
             {
                 $('#text').html('OK');
             }
             else
             {
                 $('#text').html('NO');
             }
         }
 });

Additional Methods

Name Description
toggleState Toggle the switch state
toggleAnimate Toggle the animate option
toggleDisabled Toggle the disabled state
toggleReadonly Toggle the readonly state
toggleIndeterminate Toggle the indeterminate state
toggleInverse Toggle the inverse option
destroy Destroy the instance of Bootstrap Switch

Options

Name Attribute Type Description Values Default
state checked Boolean The checkbox state true, false true
size data-size String The checkbox size null, 'mini', 'small', 'normal', 'large' null
animate data-animate Boolean Animate the switch true, false true
disabled disabled Boolean Disable state true, false false
readonly readonly Boolean Readonly state true, false false
indeterminate data-indeterminate Boolean Indeterminate state true, false false
inverse data-inverse Boolean Inverse switch direction true, false false
radioAllOff data-radio-all-off Boolean Allow this radio button to be unchecked by the user true, false false
onColor data-on-color String Color of the left side of the switch 'primary', 'info', 'success', 'warning', 'danger', 'default' 'primary'
offColor data-off-color String Color of the right side of the switch 'primary', 'info', 'success', 'warning', 'danger', 'default' 'default'
onText data-on-text String Text of the left side of the switch String 'ON'
offText data-off-text String Text of the right side of the switch String 'OFF'
labelText data-label-text String Text of the center handle of the switch String '&nbsp;'
handleWidth data-handle-width String | Number Width of the left and right sides in pixels 'auto' or Number 'auto'
labelWidth data-label-width String | Number Width of the center handle in pixels 'auto' or Number 'auto'
baseClass data-base-class String Global class prefix String 'bootstrap-switch'
wrapperClass data-wrapper-class String | Array Container element class(es) String | Array 'wrapper'
onInit   Function Callback function to execute on initialization Function
function(event, state) {}
onSwitchChange   Function Callback function to execute on switch state change Function
function(event, state) {}
$.fn.bootstrapSwitch.defaults.size = 'large'; $.fn.bootstrapSwitch.defaults.onColor = 'success';$('#toggle-state-switch').bootstrapSwitch('state');

bootstrap switch功能的更多相关文章

  1. 前端插件之Bootstrap Switch 选择框开关控制

    简介 Bootstrap Switch是一款轻量级插件,可以给选择框设置类似于开关的样式 它是依赖于Bootstrap的一款插件 下载 下载地址 在线引用 导入 因为它是依赖于Bootstrap的一款 ...

  2. bootstrap switch样式修改与多列等间距布局

    先以一张图开启今天的随笔 今天实习遇到了switch按钮,小姐姐说用插件bootstrap switch来写,我第一次用这个插件,首先在引入方面就遇到了很多坑,先来总结一下bootstrap swit ...

  3. Python_Tips[1] -> 利用 Python 的字典实现 Switch 功能

    利用 Python 的字典实现 Switch 功能 Python是没有switch语句的,当遇到需要实现switch语句的功能时,一般可以用if/else进行代替,但是还有一种更加简洁的实现方法,利用 ...

  4. python学习 05 函数switch功能

    1.python没有switch功能,利用字典实现 如果用if else,可行但是效率不高

  5. android SIM Switch功能和配置

    SIM Switch feature是Smart 3G switch feature在LTE版本号上发展演变而来的功能: MTK双卡双待单通版本号仅仅有一个3/4 G Protocol.所以同一时刻仅 ...

  6. 前端基础(十):Bootstrap Switch 选择框开关控制

    简介 Bootstrap Switch是一款轻量级插件,可以给选择框设置类似于开关的样式 它是依赖于Bootstrap的一款插件 下载 下载地址 在线引用 导入 因为它是依赖于Bootstrap的一款 ...

  7. 浅谈Bootstrap自适应功能在Web开发中的应用

    随着移动端市场的强势崛起,web的开发也变得愈发复杂,对于个体开发者来说,自己开发的网站,在电脑.手机.Pad等上面都要有正常的显示以及良好的用户体验.如果每次都要自己去调整网页去匹配各个不同的客户端 ...

  8. 使用jQuery获取Bootstrap Switch的值

    $('#switcher').bootstrapSwitch('state'); // true || false $('#switcher').bootstrapSwitch('toggleStat ...

  9. bootstrap Switch 的一个坑点

    在bootstrap的modal点开的时候改变bootstrapSwitch的状态的时候,会出现第一次打开modal,switch没有变化,第二次以后打开modal才会改变,这个问题找了好久没有找到答 ...

随机推荐

  1. HDU2050 由直线分割平面推广到折线分割平面

    直线分割平面问题: 加入已有n-1条直线,那么再增加一条直线,最多增加多少个平面? 为了使增加的平面尽可能的多,我们应该使新增加的直线与前n条直线相交,且不存在公共交点.那么我们可以将新增加的这条直线 ...

  2. ios中点语法、property跟synthesize用法

    一:OC中得点语法 1> 点语法的基本使用: ·使用 对象.成员变量   可以实现设置成员变量值,和获取成员变量的值   2> 点语法的本质 (点语法是Xcode编译器自己帮我们完成的一个 ...

  3. python 对比图片相似度

    最近appium的使用越来越广泛了,对于测试本身而言,断言同样是很重要的,没有准确的断言那么就根本就不能称之为完整的测试了.那么目前先从最简单的截图对比来看.我这里分享下python的图片相似度的代码 ...

  4. ajax遇到的问题

    今天做了个小小的实验,用ajax XMLHttpRequest对象读取服务器上的txt文件里的内容,展示出来 直接把html文件放在桌面用浏览器打开,没有反应,部分代码如下: function oHt ...

  5. 80x86的3种工作方式

    80x86中的32位CPU全面支持32位的数据.指令和寻址方式,提供了3种工作方式:是地址方式.保护方式和保护方式下的虚拟8086方式.在计算机上电或复位后,32位CPU首先初始化为是地址方式,再通过 ...

  6. Android真机连接手机Target显示unknown cmd命令下adb devices 显示offline

    主要原因是adb版本的问题: 1.找到adb.exe路径  比如:G:\BaiduYunDownload\Android\android-sdk\platform-tools,将该路径放到环境便利-- ...

  7. Ubuntu下载工具 uget+aria2

    一.安装. uget和aria2都可以在“软件中心”中安装,但是版本太老啦,无法发挥作用,所以最好还是在终端中添加ppa进行安装: 1.uget的安装:  sudo add-apt-repositor ...

  8. 关于VC中的错误处理

    include <exception> try {} cache(exception &e) { cout<<e.what()<<endl; }     但 ...

  9. Android编程之SparseArray<E>详解

    最近编程时,发现一个针对HashMap<Integer, E>的一个提示: 翻译过来就是:用SparseArray<E>来代替会有更好性能.那我们就来看看源码中SparseAr ...

  10. How to spend you day ?

    如果这是你生命中的最后的一天,你该如何去过好它呢? 不要浪费你生命中的每一分,每一秒!!!