How to handle change of checkbox using jQuery?
You can use Id of the field as well
$('#checkbox1').change(function() {
if($(this).is(":checked")) {
//'checked' event code
return;
}
//'unchecked' event code
});
Use :checkbox
selector:
$(':checkbox').change(function() {
// do stuff here. It will fire on any checkbox change
});
Code: http://jsfiddle.net/s6fe9/
Hope, this would be of some help.
$('input[type=checkbox]').change(function () {
if ($(this).prop("checked")) {
//do the stuff that you would do when 'checked'
return;
}
//Here do the stuff you want to do when 'unchecked'
});