admin管理员组文章数量:1221403
Here is my code-
<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>
Script-
$(document).ready(function() {
$('#normal-toggle-button').toggleButtons();
});
I want a basic button given on this page- Switch buttons
I am doing all right. But something i still missed.
Check in here- Fiddle
Here is my code-
<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>
Script-
$(document).ready(function() {
$('#normal-toggle-button').toggleButtons();
});
I want a basic button given on this page- Switch buttons
I am doing all right. But something i still missed.
Check in here- Fiddle
Share Improve this question edited Feb 20, 2013 at 7:23 Manoz asked Feb 20, 2013 at 5:46 ManozManoz 6,58713 gold badges71 silver badges116 bronze badges 2- you need to style it of course! – syrkull Commented Feb 20, 2013 at 5:47
- I think this post will be helpful stackoverflow.com/questions/4177159/… – Sudix Commented Feb 20, 2013 at 6:03
2 Answers
Reset to default 12The simplest use of 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>
class matters
You had the class as "toggle-button" still, change it to "switch"
Here is your updated fiddle: http://jsfiddle.net/WvRZw/10/
<div id="normal-toggle-button" class="toggle-button"....
change to
<div id="normal-toggle-button" class="switch" ....
css/javascript includes
You need to include the bootstrap javascript and css as well (see the resources section) (also regarding including javascript and css: How to get bootstrap buttons to show active state?)
本文标签: javascriptOnOff switch button bootstrapStack Overflow
版权声明:本文标题:javascript - OnOff: switch button bootstrap - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739339198a2158853.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论