<html> <head> <script language="javascript"> var i=0; function addinput(){ i++; document.getElementById("d").innerHTML+="<input type='text' id="+i+" />"; } </script> </head> <body> <button onclick="addinput()">增加文本框</button> <button onclick="addtext()">相加</button> <div id="d"></div> </body> </html>