jquery - bootstrap-switch check box value always "on" -


i developing cms , on add form i'm using bootstrap-switch in form. return checked or on value.

jsfiddle

code

<html> <head> <link rel="stylesheet" type="text/css" href="http://www.bootstrap-switch.org/docs/css/bootstrap.min.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/docs/js/bootstrap.min.js"></script> <script type='text/javascript' src="http://www.bootstrap-switch.org/dist/js/bootstrap-switch.js"></script> <script type='text/javascript'>  $(window).load(function(){      var s = $('#status').val();     $("#status").change(function(){         alert(s);     });  }); </script>  </head> <body>      <input type="checkbox" id="status" name="status" checked>  </body> </html> 

just read checked status in way:

$("#status").change(function(){     alert(this.checked); }); 

fiddle example


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -