基于Bootstrap的jQuery开关按钮组合

Bootstrap是一款由Twitter推出的开源前端开发包,功能非常强大。今天我们要分享的这款jQuery开关按钮组合就是基于Bootstrap框架的,看了按钮的主题样式,也都是Bootstrap的样式风格,比较清新和简单。这款jQuery开关按钮可以满足你不同的应用需求,包括样式、大小等。

在线预览   源码下载

实现的代码。

html代码:

<div class="container">
            <div class="row">
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">State</h2>
                <p>
                  <input id="switch-state" type="checkbox" checked>
                </p>
                <div class="btn-group">
                  <button type="button" data-switch-toggle="state" class="btn btn-default">Toggle</button>
                  <button type="button" data-switch-set="state" data-switch-value="true" class="btn btn-default">Set true</button>
                  <button type="button" data-switch-set="state" data-switch-value="false" class="btn btn-default">Set false</button>
                  <button type="button" data-switch-get="state" class="btn btn-default">Get</button>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Size</h2>
                <p>
                  <input id="switch-size" type="checkbox" checked data-size="mini">
                </p>
                <div class="btn-group">
                  <button type="button" data-switch-set="size" data-switch-value="mini" class="btn btn-default">Mini</button>
                  <button type="button" data-switch-set="size" data-switch-value="small" class="btn btn-default">Small</button>
                  <button type="button" data-switch-set="size" data-switch-value="normal" class="btn btn-default">Normal</button>
                  <button type="button" data-switch-set="size" data-switch-value="large" class="btn btn-default">Large</button>
                  <button type="button" data-switch-get="size" class="btn btn-default">Get</button>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Animate</h2>
                <p>
                  <input id="switch-animate" type="checkbox" checked>
                </p>
                <p>
                  <button type="button" data-switch-toggle="animate" class="btn btn-default">Toggle</button>
                  <button type="button" data-switch-get="animate" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Disabled</h2>
                <p>
                  <input id="switch-disabled" type="checkbox" checked disabled>
                </p>
                <p>
                  <button type="button" data-switch-toggle="disabled" class="btn btn-default">Toggle</button>
                  <button type="button" data-switch-get="disabled" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Readonly</h2>
                <p>
                  <input id="switch-readonly" type="checkbox" checked readonly>
                </p>
                <p>
                  <button type="button" data-switch-toggle="readonly" class="btn btn-default">Toggle</button>
                  <button type="button" data-switch-get="readonly" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Indeterminate</h2>
                <p>
                  <input id="switch-indeterminate" type="checkbox" checked data-indeterminate="true">
                </p>
                <p>
                  <button type="button" data-switch-toggle="indeterminate" class="btn btn-default">Toggle</button>
                  <button type="button" data-switch-get="indeterminate" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Inverse</h2>
                <p>
                  <input id="switch-inverse" type="checkbox" checked data-inverse="true">
                </p>
                <p>
                  <button type="button" data-switch-toggle="inverse" class="btn btn-default">Toggle</button>
                  <button type="button" data-switch-get="inverse" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">On Color</h2>
                <p>
                  <input id="switch-onColor" type="checkbox" checked data-on-color="info">
                </p>
                <p class="btn-group">
                  <div class="btn-group">
                    <button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle">Set &nbsp;<span class="caret"></span></button>
                    <div role="menu" class="dropdown-menu">
                      <li><a data-switch-set="onColor" data-switch-value="primary">Primary</a></li>
                      <li><a data-switch-set="onColor" data-switch-value="info">Info</a></li>
                      <li><a data-switch-set="onColor" data-switch-value="success">Success</a></li>
                      <li><a data-switch-set="onColor" data-switch-value="warning">Warning</a></li>
                      <li><a data-switch-set="onColor" data-switch-value="default">Default</a></li>
                    </div>
                  </div>
                  <button type="button" data-switch-get="onColor" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Off Color</h2>
                <p>
                  <input id="switch-offColor" type="checkbox" data-off-color="warning">
                </p>
                <p class="btn-group">
                  <div class="btn-group">
                    <button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle">Set &nbsp;<span class="caret"></span></button>
                    <div role="menu" class="dropdown-menu">
                      <li><a data-switch-set="offColor" data-switch-value="primary">Primary</a></li>
                      <li><a data-switch-set="offColor" data-switch-value="info">Info</a></li>
                      <li><a data-switch-set="offColor" data-switch-value="success">Success</a></li>
                      <li><a data-switch-set="offColor" data-switch-value="warning">Warning</a></li>
                      <li><a data-switch-set="offColor" data-switch-value="default">Default</a></li>
                    </div>
                  </div>
                  <button type="button" data-switch-get="offColor" class="btn btn-default">Get</button>
                </p>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">On Text</h2>
                <p>
                  <input id="switch-onText" type="checkbox" checked data-on-text="Yes">
                </p>
                <div class="row">
                  <div class="col-sm-6">
                    <input type="text" data-switch-set-value="onText" value="Yes" class="form-control">
                  </div>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Off Text</h2>
                <p>
                  <input id="switch-offText" type="checkbox" data-off-text="No">
                </p>
                <div class="row">
                  <div class="col-sm-6">
                    <input type="text" data-switch-set-value="offText" value="No" class="form-control">
                  </div>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Label Text</h2>
                <p>
                  <input id="switch-labelText" type="checkbox" data-label-text="Label">
                </p>
                <div class="row">
                  <div class="col-sm-6">
                    <input type="text" data-switch-set-value="labelText" class="form-control">
                  </div>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Handle Width</h2>
                <p>
                  <input id="switch-handleWidth" type="checkbox" data-handle-width="100">
                </p>
                <div class="row">
                  <div class="col-sm-6">
                    <input type="number" data-switch-set-value="handleWidth" value="100" class="form-control">
                  </div>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Label Width</h2>
                <p>
                  <input id="switch-labelWidth" type="checkbox" data-label-width="100">
                </p>
                <div class="row">
                  <div class="col-sm-6">
                    <input type="number" data-switch-set-value="labelWidth" value="100" class="form-control">
                  </div>
                </div>
              </div>
              <div class="col-sm-6 col-lg-4">
                <h2 class="h4">Create | Destroy</h2>
                <p>
                  <input id="switch-create-destroy" type="checkbox" checked data-switch-no-init>
                </p>
                <div class="row">
                  <div class="col-sm-6">
                    <button type="button" data-switch-create-destroy data-destroy-text="Destroy" class="btn btn-default">Create</button>
                  </div>
                </div>
              </div>
            </div><br><br>
            <div class="text-center">
              <h2 class="h4">Radio All Off</h2>
              <div class="row">
                <div class="col-sm-6">
                  <h3 class="h5">Disabled</h3>
                  <input type="radio" name="radio1" checked class="switch-radio1">
                  <input type="radio" name="radio1" class="switch-radio1">
                  <input type="radio" name="radio1" class="switch-radio1">
                </div>
                <div class="col-sm-6">
                  <h3 class="h5">Enabled</h3>
                  <input type="radio" name="radio2" checked data-radio-all-off="true" class="switch-radio2">
                  <input type="radio" name="radio2" data-radio-all-off="true" class="switch-radio2">
                  <input type="radio" name="radio2" data-radio-all-off="true" class="switch-radio2">
                </div>
              </div><br>
              <div style="text-align:center;clear:both;">
<script src="/gg_bd_ad_720x90-2.js" type="text/javascript"></script>
<script src="/follow.js" type="text/javascript"></script>
</div>
              <hr>
              <h2 class="h4">在模态窗口中显示</h2>
              <button data-toggle="modal" data-target="#modal-switch" class="btn btn-default">Open Modal</button>
              <div id="modal-switch" tabindex="-1" role="dialog" aria-labelledby="modal-switch-label" class="modal fade">
                <div class="modal-dialog">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" data-dismiss="modal" class="close"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                      <div id="modal-switch-label" class="modal-title">Title</div>
                    </div>
                    <div class="modal-body">
                      <input id="switch-modal" type="checkbox" checked>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>

via:http://www.w2bc.com/Article/20900

时间: 2024-08-03 16:08:51

基于Bootstrap的jQuery开关按钮组合的相关文章

基于Bootstrap的jQuery开关按钮插件

    按钮 下载 使用方法 首先要在页面中引入依赖文件: jquery.Bootstrap.Bootstrap Switch CSS和Bootstrap Switch JS.这里用的是bootstrap2 <link href="bootstrap.css" rel="stylesheet"> <link href="bootstrap-switch.css" rel="stylesheet"> &l

基于Bootstrap的JQuery TreeView树形控件,数据支持json字符串、list集合(MVC5)

BZ第一次自己写博客,心情好激动!!BZ也是小菜,本文如果有什么不对的地方,希望大神们多多指教,也希望和我一样的小菜多多学习.BZ在这里谢过各位. BZ最近看了很多博友的有关TreeView的博客,发现很多都是WebForm.JQuery的.因为BZ使用的是MVC的原因,所以决定写一写关于MVC和Bootstrap的TreeView. PS:基于Bootstrap的JQuery TreeView树形控件,JQuery版本为2.1.1(下载网上的基于Bootstrap的JQuery TreeVie

基于bootstrap的jQuery多级列表树插件

http://www.cnblogs.com/mfc-itblog/p/5233453.html http://www.htmleaf.com/jQuery/Menu-Navigation/201502141379.html http://www.htmleaf.com/Demo/201502141380.html 简要教程 bootstrap-treeview是一款效果非常酷的基于bootstrap的jQuery多级列表树插件.该jQuery插件基于Twitter Bootstrap,以简单和

基于Bootstrap使用jQuery实现简单可编辑表格

editTable.js 提供编辑表格当前行.添加一行.删除当前行的操作,其中可以设置参数,如: operatePos 用于设置放置操作的列,从0开始,-1表示以最后一列作为放置操作的列:(这里的操作包括 编辑当前行.在当前行下添加一行.删除当前行) handleFirst 设置表格的第一行是否作为操作的对象,true为真,false为假: edit.save.cancel.add.confirm.del 分别设置显示操作的操作名,默认显示"编辑"."保存".&qu

弹出框一 之 基于bootstrap和jquery的自定义弹出框

(function ($) { window.Ewin = function () { var html = '<div id="[Id]" class="modal fade" role="dialog" aria-labelledby="modalLabel">' + '<div class="modal-dialog modal-sm">' + '<div class=&

btFormbuilder.js 一个基于bootstrap的jquery插件,用于生成form表单

废话不多,用法和bootstraptable差不多 可以看git项目里面的代码看用法 git项目地址: https://github.com/lurktion/btFormbuilder

基于bootstrap的富文本框——wangEditor【欢迎加入开发】

先来一张效果图: 01. 引言 老早就开始研究富文本框的东西,在写完<深入理解javascript原型与闭包>之后,就想着要去做一个富文本框的插件的例子. 现在网络上开源的富文本框插件非常多,一搜索一大堆,但是基于bootstrap的还不多,现在只有一个“bootstrap-wysiwyg”,老外写的,没有一个汉字,大家可以fork一下源码看看,写的非常简洁,压缩之后不到10KB,非常厉害!我也还没来得及研究,一定要看一下. 02. wangEditor 老外的东西,满地英文,给程序猿用着还可

基于bootstrap的富文本框——wangEditor【欢迎增加开发】

先来一张效果图: 01. 引言 老早就開始研究富文本框的东西,在写完<深入理解javascript原型与闭包>之后,就想着要去做一个富文本框的插件的样例. 如今网络上开源的富文本框插件许多,一搜索一大堆,可是基于bootstrap的还不多.如今仅仅有一个"bootstrap-wysiwyg".老外写的,没有一个汉字.大家能够fork一下源代码看看,写的很简洁.压缩之后不到10KB.很厉害!我也还没来得及研究,一定要看一下. 02. wangEditor 老外的东西,满地英文

基于Bootstrap的DropDownList的JQuery组件的完善版

在前文 创建基于Bootstrap的下拉菜单的DropDownList的JQuery插件 中,实现了DropDownList的JQuery组件,但是留有遗憾.就是当下拉菜单出现滚动条的时候,滚动条会覆盖菜单右侧的两个圆角.使得下拉菜单左侧有2个圆角,右侧没有,看上去不是很完美.如下图所示:   本文的内容就是如何恢复右侧的圆角   先看看原本的下拉菜单的HTML结构:   .sh_darkness{background:none; padding:0; margin:0; border:0 no