jQuery can be used to access checkbox value using jQuery.attr(“value”) and it checked state using jQuery.prop("checked")
. Note that we can not use jQuery.attr() for checked state. Here is example code snippet.
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script> <input id="cb1" type="checkbox" value="val1" checked>chekbox1 <pre id="msg"></pre> <script> function display_cb_info() { var value = $("#cb1").attr("value"); var isChecked = $("#cb1").prop("checked"); $("#msg").text("value=" + value + " isChecked=" + isChecked + "\n"); } $(function() { display_cb_info(); $("#cb1").change(display_cb_info); }); </script>