Let's start with a simple checkbox like this:
<input type="checkbox" name="foo" value="bar" />
To check whether this checkbox is checked you can do either of the following two alternatives:
$('input[name=foo]').is(':checked')
$('input[name=foo]').attr('checked')
To check the checkbox we can use the attr() function
$('input[name=foo]').attr('checked', true);
And likewise to uncheck it
$('input[name=foo]').attr('checked', false);
No comments:
Post a Comment