How to check/uncheck checkbox with jquery

JQuery is a great framework and a great help bringing some eye-candy and interface richness into our webapps.

Like me, most of the web developers  don’t have the chance of learning JQuery from the top to the bottom, and all that’s left is a step-by-step approach, where the learning comes from specific needs on the current project.

Let’s see how we can check, uncheck and see the checkbox state with jquery.

Let’s think of this checkbox :

<input id="mycheck" type="checkbox" />

To see the state of the checkbox all you have to do is

var checked=$("#mycheck").attr("checked");

To check the checkbox all you have to do is

$("#mycheck").attr("checked",true);

And to uncheck the it all you have to do is

$("#mycheck").attr("checked",false);

;)

4 thoughts on “How to check/uncheck checkbox with jquery”

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA Image

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>