entry 诡异的radio表单问题

今天做项目的时候,发现了这个诡异的问题:js动态创建的radio元素在IE下不能被选中的问题。

点这里看这个诡异的问题

第一种情况用document.createElement创建input元素,然后用setAttribute为它设定type=radio,不过在IE下的效果,一点便知,不能选择...

第二种情况用innerHTML直接把input type="radio" name="radio2"输出,却是可以的,无语了...

希望知道原因的朋友不吝赐教。

Related Posts

4 Responses to 诡异的radio表单问题

  1. IE没有解析到name属性,用maxthon的viewpage可以看出来,缺一个name属性

  2. 奇怪的是用微软的IE DevToolBar也不能给它加上name值...

  3. 不是所有的浏览器都可以改name的,可能是出于安全性的考虑吧。

  4. http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onclick.asp

    Microsoft JScript allows the name to be changed at run time. This does not cause the name in the programming model to change in the collection of elements, but it does change the name used for submitting elements.

    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.

Leave a Reply

Mail will not be published