I have a problem with unchecking a checkbox
. Have a look at my jsFiddle, where I am attempting:
$("#check2").attr("checked", true);
I use uniform for styling the checkbox
and it simply does not work to check/uncheck the checkbox
.
Any ideas?
A simpler solution is to do this rather than using uniform:
$('#check1').prop('checked', true); // will check the checkbox with id check1
$('#check1').prop('checked', false); // will uncheck the checkbox with id check1
This will not trigger any click action defined.
You can also use:
$('#check1').click(); //
This will toggle the check/uncheck for the checkbox but this will also trigger any click action you have defined. So be careful.
EDIT: jQuery 1.6+ uses prop()
not attr()
for checkboxes checked value