tags:

views:

75

answers:

3

I have a form like below:

   <form id="toppings_div" name="form1" method="post" action="">
                            <table width="355">
                              <tr>
                                <td>
                                  <input type="checkbox" value="Cheese" />
                                  <label>Extra cheese</label>
                                </td></tr></table></from>

I was just wondering how I can get to the value of the checkbox if it's checked.

thanks

        alert($('#toppings_div').children().children().children().children(':checked').val());

using the code above gives me an undefined answer,

thanks

A: 

Try .checked()

Marius
+1  A: 

Thanks for the help,

I found the answer,

alert($('input:checked').val() );

amir
This will get you the value of the **first** checked input on your page, make sure that's what you want.
Kobi
+1  A: 

$('#toppings_div input:checkbox:checked').val() is all that's needed. The > in the selector means direct descendant of.

smack0007