没有name属性的radio是不可选的

解决方案 »

  1.   

    var tjtb=document.getElementById("tjtb");
    var input=document.createElement("<input type=radio name=a value=男>");
    tjtb.appendChild(input)
      

  2.   

    刚才试了一下,发现的确还是不行,查了下MSDN发现这句话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.ExamplesThe following example shows how to set the NAME attribute on a dynamically created A element.var oAnchor = document.createElement("<A NAME='AnchorName'></A>");
    楼主这样试试
    var input = document.createElement("<input NAME='Name'></input>");
      

  3.   

    var tjtb=document.getElementById("tjtb");
    var input=document.createElement("<input type=radio name=a value=男>");
    tjtb.appendChild(input)
    var t = document.createTextNode("男")
    tjtb.appendChild(t)input=document.createElement("<input type=radio name=a value=女>");
    tjtb.appendChild(input)
    t = document.createTextNode("女")
    tjtb.appendChild(t)
      

  4.   

    NoThiNg2050(子虚乌有) 谢谢你 但我文本筐是可以这样添name的
    谢谢
      

  5.   

    1、radio在没有name属性时是选择不了的,name属性起了对几个radio分组的作用,而checkbox没有此限制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.
    name属性不能在运行过程中进行变更,只能在创建时指定