Checkbox value 0 or 1 - Javascript jQuery

Javascript examples for jQuery:Form Checkbox

Description

Checkbox value 0 or 1

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.0.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  w  w  w  .j  ava 2 s  .  c o m
$('input[type="checkbox"]').change(function(){
    this.value ^= 1;
    console.log(this.value);
});
    });

      </script> 
 </head> 
 <body> 
  <input type="checkbox" name="custom7" value="1" id="custom7" checked> 
  <label for="custom7">Email me more info?</label>  
 </body>
</html>

Related Tutorials