jQuery IE8 单选按钮问题
我有这样一种奇怪的情况 - 有单选按钮设置:
<%= radio_button_tag 'include_test', false, true %>
<%= radio_button_tag 'include_test', true %>
我正在尝试获取选中的单选按钮的值 - 在 Chrome 和 FF 中它返回 1 个值,在 IE 中它返回包含 2 个值的数组 ("include_test"=>["false" ,“真”]
)。我尝试了不同的方法来解决这个问题,但在 IE 中总是得到相同的结果。
$('input[name=include_test]').val()
有
$('input[name=include_test]:checked').val()
什么
$('input[name=include_test]:checked').fieldValue()
解决办法吗?
HTML 如下:
<input checked="checked" id="include_test_false" name="include_test" type="radio" value="false" />
<input id="include_test_true" name="include_test" type="radio" value="true" />
I have such kind of strange situation -
there is radio button set:
<%= radio_button_tag 'include_test', false, true %>
<%= radio_button_tag 'include_test', true %>
And I'm trying to get the checked radio button's value - in Chrome and FF it returns 1 value, in IE it returns array with 2 values ("include_test"=>["false", "true"]
). I have tried different ways to solve that, but always same result in IE.
$('input[name=include_test]').val()
with
$('input[name=include_test]:checked').val()
and
$('input[name=include_test]:checked').fieldValue()
Any solution?
Here goes HTML:
<input checked="checked" id="include_test_false" name="include_test" type="radio" value="false" />
<input id="include_test_true" name="include_test" type="radio" value="true" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 IE8 中测试了这个jsfiddle,它工作正常。这是使用你的第二个例子。
I tested this jsfiddle in IE8, it works fine. This is using your second example.
我认为你的代码正在运行。
http://jsfiddle.net/gPM5L/
我已经在 IE9 和 IE9 的 IE8 模式下进行了测试,它看起来它正在工作。您是否想对这个值做一些更具体的事情?
I think that your code is working.
http://jsfiddle.net/gPM5L/
I have tested in IE9, and in IE9's IE8 mode, and it looks like it's working. Are you trying to do anything more specific with the value?