I have a form with multiple checkboxes. I also have the following code to return the state of these checkboxes.
A) returns "undefined"
B) returns "on" no matter if it is checked or not.
C,D) if I check just C then it also sets D to "true".I only want C to be "true".
$('#button').click(
function() {
var A = $('#id_a').attr('checked');
var B = $('#id_b').val();
var C = $('#id_c').is(':checked');
var D = $('#id_d').is(':checked');
$.ajax({
url: "test.php",
type: "GET",
data: "&A="+A+"&B="+B+"&C="+C+"&D="+D,
success: function(data) {
$('#display').html(data);
}
});
}
);
Thanks in advance
.prop('checked').. That should get you the right state of the checked propertyattr()andprop()since jQuery 1.7: api.jquery.com/prop vs. api.jquery.com/attr