Alex Rivera | Logout

How to make a checkbox checked with jQuery?

Asked 2011-07-27T20:11:53.703
67

Possible Duplicate:
How do I check a checkbox with JQuery or Javascript?

I'm trying to make a checkbox checked (or not) with jQuery.

My example HTML:

<input type="checkbox" id="test" name="test" />

Attempt at clearing a checkbox(doesn't work)

$('#test').val('off');

and at checking:

$('#test').val('on');

How do I control checkboxes with jQuery?

Edit
Report

1 Answer

12
$('#test').attr('checked','checked');

$('#test').removeAttr('checked');
answered 2011-07-27T20:13:56.057

Your Answer