Sam*_*son 1 html jquery radio-button
鉴于以下代码,即使在用户选择了radiobutton 2之后,jQuery似乎也只提醒"1"作为值.我在这里缺少什么?当选择第二个radiobutton时,不应该跟踪jQuery警告"2"吗?
<p>
Coal <input type="radio" name="example" value="1" checked />
Candy <input type="radio" name="example" value="2" />
</p>
Run Code Online (Sandbox Code Playgroud)
我在firebug中使用此代码来测试:
r = $(":radio[name='example']").val();
alert(r);
Run Code Online (Sandbox Code Playgroud)
$(":radio[name='example']")为您提供名称= example的所有无线电,.val()然后获取第一个的值.你要$(":radio[name='example']:checked").val()
| 归档时间: |
|
| 查看次数: |
690 次 |
| 最近记录: |