2010-01-05 84 views
0

干草,我怎么能得到这个值?即选择哪一个。jQuery,单选按钮获得值

<input type='radio' name="thing" value="on" checked> 
<input type='radio' name="thing" value="off"> 

我不能与

$("input[name='thing']").val() 

感谢

回答

4

如何获得的价值:

$("input[name='thing']:checked").val() 
+2

钍e @ style在jQuery 1.3中被弃用,并且不会工作,参考:http://docs.jquery.com/Selectors/attributeHas#attribute – tvanfosson 2010-01-05 15:12:43

+0

编辑它...看起来不像作者会改变它。 – James 2010-01-05 15:34:54

+0

thx为编辑。 – easement 2010-01-06 19:45:39

1

找到解决

$("input[name='thing']:checked").val()