Ok, there are similar answers already. I'm gonna post this anyway since I spent some time making it work and learning something new. Doesn't work with v1.6
http://jsfiddle.net/gsndd/
http://jsfiddle.net/gsndd/2/
$(function() {
// Ripped from https://github.com/mjball/jQuery-CheckAll @Matt Ball
var propFn = typeof $.fn.prop === 'function' ? 'prop' : 'attr';
$('#checkall').click(function() {
$(this).parents('fieldset:eq(0)').find(':checkbox')[propFn]('checked', this.checked);
});
$("input[type=checkbox]:not(#checkall)").click(function() {
if (!this.checked) {
$("#checkall")[propFn]('checked', this.checked);
} else {
$("#checkall")[propFn]('checked', !$("input[type=checkbox]:not(#checkall)").filter(':not(:checked)').length);
}
});
});
EDIT: To make the same work with v1.6+, just change the attr to prop. Ultimately, you are better off using something that works with both.
Edit - Fixed the code to work on any version(assuming John won't come up with v1.7 and say, 'surprise').
Thanks to @Matt Ball