Js动态生成Input标签
在IE中input.name不能正常赋值:
由于Name属性在不同浏览器赋值不同,所以在操作时应该注意。
/**生成Input标签**/
function generateInput(type,id,name){
var input;
if(document.all){
if(name != null && name != ""){
input = document.createElement('<input name="' + name + '">');//IE代码
}else{
input = document.createElement('<input');//IE代码
}
}else{
input = document.createElement('input'); //其他
if(name != null && name != ""){
input.name = name;
}
}
if(type == null || type == ""){
type = "text"
}else{
input.type = type;
}
if(id != null && id != ""){
input.id = id;
}
input.value = "";
//document.body.applyElement(input);
document.body.appendChild(input);
};
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
蕃薯耀 2013年12月7日 15:28:02 星期六

本文介绍了一种使用JavaScript动态创建HTML Input元素的方法,并特别针对Internet Explorer浏览器中的name属性问题提供了解决方案。
111

被折叠的 条评论
为什么被折叠?



