Get state of checkbox using javascript - Javascript jQuery

Javascript examples for jQuery:Form Checkbox

Description

Get state of checkbox using javascript

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-1.8.3.js"></script> 
  <script type="text/javascript">
    $(function(){/*from   www .java 2s. co  m*/
(function ($) {
    "use strict";
    $(document).ready(function () {
        $('#edit-toggle-me').click(function(){
            console.log( this.checked ? ":)" : ":(" );
        });
    });
})(jQuery);
    });

      </script> 
 </head> 
 <body> 
  <input type="checkbox" id="edit-toggle-me">  
 </body>
</html>

Related Tutorials