当前位置: 首页 > 新闻动态 > 软件编程

IE6不能修改NAME问题的解决方法

作者:用户投稿 浏览: 发布日期:2026-01-16
[导读]:昨天在项目中发现IE6动态生成的INPUT是不能改NAME的,微软关于这个问题有这么个说法
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.
也就是说,你得这么写
复制代码 代码如下:
document.createElement('<input type="text" name="username" >');

看起来都觉得不爽,而且不支持FF.
如果你使用了Jquery的clone方法,然后想在复制之后修改元素的name属性,那是不会成功的,简单一点的办法是新建一个,然后删掉原来那个。
复制代码 代码如下:
$('<input type="text" name="username" />').appendTo(xxx.parent());
xxx.remove();
免责声明:转载请注明出处:http://m.jing-feng.com.cn/news/52065.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!