开发者

radio button jquery ie6 problem

i am dynamically creating radio using jquery as shown belown. but they value only selected in ff,ie8. ie6,ie7 not selecting the values. how can i select the radio button value in ie6/7.

rand=$("<input type='radio' ></input>");
rand.attr("checked"开发者_JS百科,"checked");
$(document).append(rand);


My guess is that <input> does not have a closing tag.


Also give it a name attribute. If need be, set the checked attribute after appending to the DOM.

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. 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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜