I Am using jquery 1.6.1 for checking all a group of checkboxes.
this is my HTML Code:
<form action="">
<div class="stats">
<h2 class="title">Reason for Celebrity</h2>
<input name="reason" type="checkbox" value="net" />Famous on the internet<br/>
<input name="reason" type="checkbox" value="crim" />Committed a crime<br />
<input name="reason" type="checkbox" value="model" />Dates a super model<br />
<input name="reason" type="checkbox" value="tv" />Hosts a TV show<br />
<input name="reason" type="checkbox" value="japan" />Big in Japan<br />
<hr />
<input class="check-all" name="reason" type="checkbox" /><span>Check all</span>
<br/>
<input type="submit" value="Submit" class="submit" />
</div>
</form>
and my script for check all is like this:
$(document).ready(function(){
$('.check-all:checkbox').change(function() {
var group = ':checkbox[name=' + $(this).attr('name') + ']';
$(group).attr('checked', $(this).attr('checked'));
});
});
but this not work on uncheck of checkboxes. can you help me solve this problem?
Try to replace
with