views:

533

answers:

3

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","checked");
$(document).append(rand);
+2  A: 

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

pestaa
+1  A: 

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);
Russ Cam
A: 

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!

Funka