Bootstrap Tutorial - Create bootstrap switch








The following code shows how to create bootstrap switch.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-2.0.2.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://getbootstrap.com/dist/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
  href="http://www.bootstrap-switch.org/dist/css/bootstrap3/bootstrap-switch.css">
<script type='text/javascript'
  src="http://www.bootstrap-switch.org/dist/js/bootstrap-switch.js"></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!--from   w  w w.  ja  v a 2 s  . com-->
    $("input.switch").bootstrapSwitch();
});//]]>  
</script>
</head>
<body>
  <div>
    Default On: <input type="checkbox" class="switch" checked />
  </div>
  <div>
    Default Off: <input type="checkbox" class="switch" />
  </div>
  <!-- Post Info -->
  <div
    style='position: fixed; bottom: 0; left: 0; background: lightgray; width: 100%;'>
    About this SO Question: <a
      href='http://stackoverflow.com/q/24533554/1366033'>Bootstrap
      Switch - ON state</a><br /> Fork This Skeleton Here: <a
      href='http://jsfiddle.net/KyleMit/kcpma/'>Bootstrap 3.0 Skeleton</a><br />
    <div>
</body>
</html>

Click to view the demo