How to use Javascript to create a checked radioButton in IE?
        Posted  
        
            by Chris
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Chris
        
        
        
        Published on 2010-05-12T02:28:33Z
        Indexed on 
            2010/05/12
            2:34 UTC
        
        
        Read the original article
        Hit count: 272
        
JavaScript
|html
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?
© Stack Overflow or respective owner