如何获取已选中复选框的值 [英] how to get the value of a checked checkbox
本文介绍了如何获取已选中复选框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的表单如下:
<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.
谢谢
alert($('#toppings_div').children().children().children().children(':checked').val());
使用上面的代码给我一个未定义的答案,
using the code above gives me an undefined answer,
谢谢
推荐答案
我使用以下代码行解决了我的问题:
I used the following line of code to solve my problem:
alert($('input:checked').val() );
这篇关于如何获取已选中复选框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文