【发布时间】:2009-12-23 05:23:03
【问题描述】:
所以当我点击按钮时,javascript 会添加新字段。目前它在旁边添加了新的文本框..有没有办法让它在下面添加?我猜好像有一个
。
这是代码。谢谢!
<html>
<head>
<script type="text/javascript">
var instance = 1;
function newTextBox(element)
{
instance++;
var newInput = document.createElement("INPUT");
newInput.id = "text" + instance;
newInput.name = "text" + instance;
newInput.type = "text";
//document.body.write("<br>");
document.body.insertBefore(newInput, element);
}
</script>
</head>
<body>
<input id="text2" type="text" name="text1"/> <br>
<input type="button" id="btnAdd" value="New text box" onclick="newTextBox(this);" />
</body>
【问题讨论】:
标签: javascript html field