1//jQuery listen for checkbox change
2$("#myCheckBoxID").change(function() {
3 if(this.checked) {
4 //I am checked
5 }else{
6 //I'm not checked
7 }
8});
1$(document).ready(function() {
2 //set initial state.
3 $('#textbox1').val($(this).is(':checked'));
4
5 $('#checkbox1').change(function() {
6 if($(this).is(":checked")) {
7 var returnVal = confirm("Are you sure?");
8 $(this).attr("checked", returnVal);
9 }
10 $('#textbox1').val($(this).is(':checked'));
11 });
12});
1$('#checkbox1').mousedown(function() {
2 if (!$(this).is(':checked')) {
3 this.checked = confirm("Are you sure?");
4 $(this).trigger("change");
5 }
6});
1$(document).ready(function() {
2 //set initial state.
3 $('#textbox1').val(this.checked);
4
5 $('#checkbox1').change(function() {
6 if(this.checked) {
7 var returnVal = confirm("Are you sure?");
8 $(this).prop("checked", returnVal);
9 }
10 $('#textbox1').val(this.checked);
11 });
12});