[英]radio button jquery ie6 problem
i am dynamically creating radio using jquery as shown belown. 我正在使用jquery动态创建收音机,如下所示。 but they value only selected in ff,ie8.
但它们只值在ff,ie8中选择的值。 ie6,ie7 not selecting the values.
ie6,ie7未选择值。 how can i select the radio button value in ie6/7.
我如何在ie6 / 7中选择单选按钮值。
rand=$("<input type='radio' ></input>");
rand.attr("checked","checked");
$(document).append(rand);
我的猜测是<input>
没有结束标记。
Also give it a name
attribute. 还给它一个
name
属性。 If need be, set the checked
attribute after appending to the DOM. 如果需要,请在附加到DOM后设置
checked
属性。
You could also do it like so 你也可以这样
rand=$("<input type='radio' checked='checked' name='radio'/>");
$(document).append(rand);
Besides the missing name
attribute as Russ Cam mentioned, and also losing the </input>
, your radio button should also have a value
. 除了Russ Cam提到的缺少
name
属性,并且丢失</input>
,您的单选按钮还应该具有一个value
。 My guess is the browser relies on value especially for radios, to implement the "only one can be checked at a time" functionality... 我的猜测是浏览器特别是对于无线电依赖于价值,以实现“一次只能检查一个”功能...
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.