尝试获取选定的单选按钮值时,jQuery 抛出错误
给定这个单选按钮集:
<div id="reviewScope">
<input type="radio" name="loadMarkers" id="day" value="day"><label for="day">24 Hours</label>
<input type="radio" name="loadMarkers" id="week" value="week"><label for="week">Week</label>
<input type="radio" name="loadMarkers" id="month" value"month"><label for="month">Month</label>
</div>
然后使用 jQuery 1.5.2 调用,我试图获取答案后所选单选按钮的值 此处:
$('#reviewScope input:radio').change(function() {
period = $("input[name='loadMarkers']:checked").val();
....
}
Firebug 抛出错误:
$("input[name='loadMarkers']:checked").val 不是函数
什么是我做错了吗?
Given this radio button set:
<div id="reviewScope">
<input type="radio" name="loadMarkers" id="day" value="day"><label for="day">24 Hours</label>
<input type="radio" name="loadMarkers" id="week" value="week"><label for="week">Week</label>
<input type="radio" name="loadMarkers" id="month" value"month"><label for="month">Month</label>
</div>
Then calling using jQuery 1.5.2, I'm trying to get the value of the selected radio button following the answer here:
$('#reviewScope input:radio').change(function() {
period = $("input[name='loadMarkers']:checked").val();
....
}
Firebug is throwing the error:
$("input[name='loadMarkers']:checked").val is not a function
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否缺少更改方法中的结束符“)”?
http://jsfiddle.net/67Q68/
Are you missing the closing ')' in the change method?
http://jsfiddle.net/67Q68/
您可以这样做:
检查右括号和方括号
You can do this:
Check for closing parenthesis and brackets
与其他单选按钮一一执行相同的操作
Do the same as for other radio buttons one by one