I’ve tried various methods to get my checkboxes to be checked upon a click.
The following works on document ready:
$('input[name=foo]').attr("checked","checked");
However as soon as I surround it with a click event the checkboxes won’t maintain checked state. On the click they check (as they should) and then immediately uncheck.
$("#selectall").click(function(){
$('input[name=foo]').attr("checked","checked");
});
My HTML:
<form id="frm1">
<input type="checkbox" name="foo" value="bar" />
</form>
Use…