日期:2014-05-16  浏览次数:20314 次

如何动态生成文本框,也可以删除!
支持FIREFOX麻烦大虾们帮忙!还有怎么获得动态生成的文本框中有输入的值!

------解决方案--------------------
var ipt = document.createElement( "input ");
ipt.type= "text ";
document.body.appendChild(ipt);
document.body.removeChild(ipt);
------解决方案--------------------
<html>
<body>
<script>
function Add(){
var txt=document.createElement( "input ")
txt.type= "text ";
txt.id= "txt ";
document.getElementById( "div ").appendChild(txt);
}
function Remove(){
var txt=document.getElementById( "txt ");
txt.parentNode.removeChild(txt);
}
</script>

<div id= "div "> </div>
<input type= "button " onclick= "Add() " value= "添加 " />
<input type= "button " onclick= "Remove() " value= "删除 " />
</body>
</html>