2011-04-15 79 views
0

我有这样一种奇怪的局面 - 有单选按钮组:jQuery的IE8单选按钮问题

<%= 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" /> 
+0

您可以发布'radio_button_tag'生成的HTML代码。在表面值,没有理由为什么你的第二个例子使用':checked.val()'不起作用。 – 2011-04-15 08:54:34

回答

0

我在IE8中测试了jsfiddle,它工作正常。这是使用你的第二个例子。

0

我认为您的代码工作。

http://jsfiddle.net/gPM5L/

我已经在IE9测试,并在IE9的IE8模式,它看起来像它的工作。你是否试图做更具体的价值?

+0

没有执行特定操作,我只是使用fieldValue()选择值。 – thesis 2011-04-15 09:39:01

+0

相同的区别,'.val()'和'.fieldValue()'是不同的 – 2011-04-15 13:09:49