maztt maztt - 1 year ago 114
HTML Question

Get checkbox value in jQuery

How can I get a checkbox's value in jQuery?

Answer Source

To get the value of the Value attribute you can do something like this:


Or if you have set a class or id for it, you can:


However this will return the same value whether it is checked or not, this can be confusing as it is differnt to the submitted form behaviour.

To check whether it is checked or not, do:

if ($('#check_id').is(":checked"))
  // it is checked
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download