Prasad Prasad - 1 year ago 92
jQuery Question

How to check if a checkbox is checked in jQuery?

I need to check the

property of a checkbox and perform an action based on the checked property using jQuery.

For example, if the age checkbox is checked, then I need to show a textbox to enter age, else hide the textbox.

But the following code returns
by default:

if($('#isAgeSelected').attr('checked')) {
} else {

How do I successfully query the

Answer Source

This worked for me:

$get("isAgeSelected ").checked == true

Where isAgeSelected is the id of the control.

Also, @karim79's answer works fine. I am not sure what I missed at the time I tested it.

Note, this is answer uses Microsoft Ajax, not jQuery

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download