9

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

Manoz
  • 6,507
  • 13
  • 68
  • 114

2 Answers2

12

The 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>
Steely Wing
  • 16,239
  • 8
  • 58
  • 54
-1

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?)

Community
  • 1
  • 1
Amir T
  • 2,708
  • 18
  • 21
  • Ok, everything in your code was about "toggle-button". Also needed the base bootstrap js/css. – Amir T Feb 20 '13 at 06:22