bootstrap switch功能
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 | ' ' |
| 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 |
|
|
| onSwitchChange | Function | Callback function to execute on switch state change | Function |
|
$.fn.bootstrapSwitch.defaults.size = 'large'; $.fn.bootstrapSwitch.defaults.onColor = 'success';$('#toggle-state-switch').bootstrapSwitch('state');
bootstrap switch功能的更多相关文章
- 前端插件之Bootstrap Switch 选择框开关控制
简介 Bootstrap Switch是一款轻量级插件,可以给选择框设置类似于开关的样式 它是依赖于Bootstrap的一款插件 下载 下载地址 在线引用 导入 因为它是依赖于Bootstrap的一款 ...
- bootstrap switch样式修改与多列等间距布局
先以一张图开启今天的随笔 今天实习遇到了switch按钮,小姐姐说用插件bootstrap switch来写,我第一次用这个插件,首先在引入方面就遇到了很多坑,先来总结一下bootstrap swit ...
- Python_Tips[1] -> 利用 Python 的字典实现 Switch 功能
利用 Python 的字典实现 Switch 功能 Python是没有switch语句的,当遇到需要实现switch语句的功能时,一般可以用if/else进行代替,但是还有一种更加简洁的实现方法,利用 ...
- python学习 05 函数switch功能
1.python没有switch功能,利用字典实现 如果用if else,可行但是效率不高
- android SIM Switch功能和配置
SIM Switch feature是Smart 3G switch feature在LTE版本号上发展演变而来的功能: MTK双卡双待单通版本号仅仅有一个3/4 G Protocol.所以同一时刻仅 ...
- 前端基础(十):Bootstrap Switch 选择框开关控制
简介 Bootstrap Switch是一款轻量级插件,可以给选择框设置类似于开关的样式 它是依赖于Bootstrap的一款插件 下载 下载地址 在线引用 导入 因为它是依赖于Bootstrap的一款 ...
- 浅谈Bootstrap自适应功能在Web开发中的应用
随着移动端市场的强势崛起,web的开发也变得愈发复杂,对于个体开发者来说,自己开发的网站,在电脑.手机.Pad等上面都要有正常的显示以及良好的用户体验.如果每次都要自己去调整网页去匹配各个不同的客户端 ...
- 使用jQuery获取Bootstrap Switch的值
$('#switcher').bootstrapSwitch('state'); // true || false $('#switcher').bootstrapSwitch('toggleStat ...
- bootstrap Switch 的一个坑点
在bootstrap的modal点开的时候改变bootstrapSwitch的状态的时候,会出现第一次打开modal,switch没有变化,第二次以后打开modal才会改变,这个问题找了好久没有找到答 ...
随机推荐
- POJ 2318 TOYS 叉积
题目大意:给出一个长方形盒子的左上点,右下点坐标.给出n个隔板的坐标,和m个玩具的坐标,求每个区间内有多少个玩具. 题目思路:利用叉积判断玩具在隔板的左方或右方,并用二分优化查找过程. #includ ...
- shell注意事项
以下基于bash 1.shell只有变量和数组?,数组() 2.( (表达式1,表达式2…) ) 3.[ expr ] 实际上是bash 中 test 命令的简写.即所有的 [ expr ] 等于 t ...
- preg_replace 方法
标红关键字 $text = "Sample sentence from KomunitasWeb, regex has become popular in web programming. ...
- 用python计算md5,sha1,crc32
Linux下计算md5sum,sha1sum,crc: 命令 输出 $md5sum hello f19dd746bc6ab0f0155808c388be8ff0 hello $sha1sum hel ...
- js框架——angular.js
这是一个前端用的框架,使用简单.详细介绍这里就不写了,主要介绍其语法和作用—— 1. 声明一个angular 如果想要使用一个angular代码,则需要在[想要使用angular的范围内写上ng-ap ...
- elasticsearch 手动控制分片分布
elasticsearch可以通过reroute api来手动进行索引分片的分配. 不过要想完全手动,必须先把cluster.routing.allocation.disable_allocatio ...
- Bootstrap学习 - JavaScript插件
模态框 <div class="modal" id="myModal" tabindex="-1" role="dialo ...
- PAT (Advanced Level) 1114. Family Property (25)
简单DFS. #include<cstdio> #include<cstring> #include<cmath> #include<vector> # ...
- struts2 严重: Error filterStart 原因
当然你也可以用最新的struts2.3,把相应的包拷贝到工作区lib里 使用struts2.3.1所需的JAR包commons-fileupload-1.2.2.jarcommons-logging- ...
- Cisco设备IOS的恢复方法 两种方法
如果不小心把Router或者Switch的IOS删除了,特别是Flash中的IOS和ROM中的Mini IOS都没有了的话,连启动都不行的话,有什么方法恢复它呢?答案是方法不只一种,而是两种.其实是我 ...