var b = document.createElement("<INPUT name='a'>");

解决方案 »

  1.   


    <body>
    </body>
    <script>
    var b = document.createElement("<INPUT type=radio name='a'>");
    var t =  document.createTextNode("aa");
    document.body.appendChild(b)
    document.body.appendChild(t)b = document.createElement("<INPUT type=radio name='a'>");
    t =  document.createTextNode("bb");
    document.body.appendChild(b)
    document.body.appendChild(t)
    </script>
      

  2.   

    The NAME attribute cannot be set at run time on elements dynamically created with the createElement method. To create an element with a name attribute, include the attribute and value when using the createElement method
      

  3.   

    谢谢楼上两位,但都不兼容firefox...
    不知道firefox有什么方法。。
      

  4.   

    if(!document.all){//FF
       var a = document.createElement("INPUT");
       a.type="radio";a.name = "ba";
       document.body.appendChild(a);
    }
    else{//IE
       var b = document.createElement("<INPUT type=radio name='a'>");
       var t =  document.createTextNode("aa");
       document.body.appendChild(b)
       document.body.appendChild(t)
    }