How to use Javascript to create a checked radioButton in IE?
- by Chris
I was trying to create a checked radiobutton by using following code in IE7. But it doesn't work.
var x = document.createElement("");
var spn=document.createElement("span");
spn.appendChild(x);
x.checked=true;
document.body.appendChild(spn);
I found that I could put x.checked=true after appendChild statement to make it work. I also noticed that when I change "radio" to "checkbox", it can be checked without changing the order of statements.
I am really confused by these facts. Am I doing something wrong in the above code?