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. Integer比较值的时候小心使用

    package integerdemo; public class IntegerDemo { public static void main(String[] args) { //-128--127 ...

  2. Loadrunner之文件的上传(八)

    老猪提供: https://mp.weixin.qq.com/s?__biz=MzIwOTMzNDEwNw==&mid=100000013&idx=1&sn=624f5bc74 ...

  3. FZU 1914 Funny Positive Sequence(线性算法)

    这个当时我没有做出来,看了很多人包括学长的代码才懂,我感觉最好的方法还是下面那一种,标记以谁开头的是不行的,我感觉有点不好理解,如果不懂举组样例在纸上写一下就会比较清楚了 #include<io ...

  4. 转:Loadrunner学习知多少--脚本录制下载操作

    在很多时候我们可能需要对系统进行这样的脚本开发,模拟用户点击一个下载链接,然后弹出下载框,选择保存,用来测试在大量用户下载时服务器的性能.但是现在大家对于这种脚本的处理方式往往是通过关联和C 语言的文 ...

  5. php basename()文件夹 路径 文件后缀名 读取pathinfo()

    $path = "/www/mywebsite/images/myphoto.jpg"; 1.pathinfo()函数 pathinfo()函数返回的是一个包含了文件信息的数组,数 ...

  6. 使用MyBatis的Generator自动创建实体类和dao的接口与xml

    在实际的项目中其实建立数据库和设计数据库的时候特别重要,而等数据库设计完成之后,根据数据库创建实体类的工作就特别麻烦和繁琐了,不仅很麻烦,而且很浪费时间,不做又不行,这次就找到了一个简单的方法可以让m ...

  7. ListView显示多种类型的item

    ListView可以显示多种类型的条目布局,这里写显示两种布局的情况,其他类似 这是MainActivity:,MainActivity的布局就是一个ListView public class Mai ...

  8. jquery获取页面相关尺寸

    $(windows).width();获取页面可视宽度 $(windows).height();获取页面可视高度 $(document).height();获取页面内容的总高度 $(document) ...

  9. 用telnet命令,POP3接收邮件

    昨天已经成功利用telnet命令发送了邮件,今天接着来,只能发送不能接收多郁闷. 邮件的接收这里是基于pop3协议的,pop3协议共定义了12条与接收相关的邮件,如下面简单解释: 首先是与登陆验证相关 ...

  10. 服务器遭受 ssh 攻击

    查看auth.log日志,差点吓一跳,好多攻击记录. vim  /var/log/auth.log 才两天的功夫,900多万条记录, 一些解决应对的办法: 43down voteaccepted It ...