how can i get the checkbox value in jquery
+1
A:
Like this:
$("input[type='checkbox']").val();
Or if you have set a class or id for it, you can:
$('#check_id').val();
$('.check_class').val();
Also you can check whether it is checked or not like:
if ($('#check_id').is(":checked"))
{
// it is checked
}
Sarfraz
2010-05-14 13:10:07
What does the first example do if there are multiple checkboxes on the page? Btw, it can be written in a shorter way `$("input:checkbox")`. Also, there seems to be a typo in the class selector...
Jawa
2010-05-14 13:36:24
@Jawa: The first one was just an example to show the syntax and thanks for that typo.
Sarfraz
2010-05-14 13:38:41
+1
A:
a quick search of this site is better than a quick post
look at this tread your question is too basic
mcgrailm
2010-05-14 13:12:15