【发布时间】:2011-04-15 08:46:19
【问题描述】:
我有这种奇怪的情况- 有单选按钮设置:
<%= radio_button_tag 'include_test', false, true %>
<%= radio_button_tag 'include_test', true %>
我正在尝试获取选中的单选按钮的值 - 在 Chrome 和 FF 中它返回 1 个值,在 IE 中它返回具有 2 个值的数组 ("include_test"=>["false", "true"])。我尝试了不同的方法来解决这个问题,但在 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" />
【问题讨论】:
-
您能否发布
radio_button_tag生成的HTML 代码。从表面上看,您使用:checked.val()的第二个示例没有理由不起作用。
标签: jquery html ruby-on-rails internet-explorer-8