【问题标题】:On/Off: switch button bootstrap开/关:开关按钮引导
【发布时间】:2013-02-05 01:19:42
【问题描述】:

这是我的代码-

<div id="normal-toggle-button" class="toggle-button" style="width: 100px; height: 25px;">
            <div style="left: 0px; width: 150px;"><input type="checkbox" checked="checked"><span class="labelLeft" style="width: 50px; height: 25px; line-height: 25px;">ON</span><label for="" style="width: 50px; height: 25px;"></label><span class="labelRight" style="width: 50px; height: 25px; line-height: 25px;">OFF </span></div>
        </div>
    </div>

脚本-

$(document).ready(function() {
        $('#normal-toggle-button').toggleButtons();
    });

我想要这个页面上的基本按钮-Switch buttons

我做得很好。但我仍然错过了一些东西。

在这里签到- Fiddle

【问题讨论】:

标签: javascript jquery twitter-bootstrap uiswitch


【解决方案1】:

bootstrapSwitch的最简单使用

Demo

<link href="bootstrap-switch.css" rel="stylesheet">
<script src="jquery.js"></script>
<script src="bootstrap-switch.js"></script>

<input type="checkbox">
<script>
  $('input:checkbox').bootstrapSwitch();
</script>

【讨论】:

  • 这似乎不再有效。也许最新版本的引导程序坏了?
  • @WingLeong 我想保存按钮的状态,直到它不被手动更改。有可能吗?
  • @user983983,在javascript中使用localStorage-diveintohtml5.info/storage.html
【解决方案2】:

班级事务

您仍然将课程设置为“切换按钮”,将其更改为“切换”

这是你更新的小提琴:http://jsfiddle.net/WvRZw/10/

 <div id="normal-toggle-button" class="toggle-button"....

改成

  <div id="normal-toggle-button" class="switch" ....

css/javascript 包括

您还需要包含引导 javascript 和 css(请参阅参考资料部分) (也关于包括javascript和css:How to get bootstrap buttons to show active state?)

【讨论】:

  • 好的,代码中的所有内容都是关于“切换按钮”的。还需要基本的引导 js/css。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多