作家
登录

javascript createElement()创建input不能设置name属性的解决方法

作者: 来源:www.28hudong.com 2013-03-30 02:17:08 阅读 我要评论

其中obj.name = "select";这句话并不能起到预期的作用,无论是看生成后的HTML代码还是观察使用document.getElementsByName()获取的数组长度,都会发现这个name设置并没有起作用。当然这种情况只出现在IE6和IE7中,而在FireFox中是没有问题的。     Test                   [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]   当然解决方法很简单,在创建时,使用document.createElement("<input name='select'>")。不过还不知道是什么原因?   在Name属性的说明中有这样一句话: In Internet Explorer 5, the name property cannot be set at run time on anchor objects dynamically created with the createElement method. To create an anchor with a NAME attribute, include the attribute and value when using the createElement method, or use the innerHTML property.

  推荐阅读

  学习ExtJS TextField常用方法

一、属性 fieldLabel:标签名称。 labelWidth:标签宽度。 ID:文件框ID。 二、构造参数 listeners:在对象初始化之前,将一系列事件进行绑定。 三、函数 getCmp(string _id):得到id为_id的组件对象。 getValue()>>>详细阅读


本文标题:javascript createElement()创建input不能设置name属性的解决方法

地址:http://www.17bianji.com/kaifa2/JS/27999.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)