我有一个
HTML表单.单击该按钮时,
javascript函数会添加一个新字段.我正在尝试让该功能也为该字段添加“标签”.
我已经尝试过使用document.createElement(“LABEL”),但这不允许我更改innerHtml(或者我可能做错了..),也没有添加结束
这是我的代码.谢谢!
var instance = 2;
function newTextBox(element)
{
instance++;
// Create new input field
var newInput = document.createElement("INPUT");
newInput.id = "text" + instance;
newInput.name = "text" + instance;
newInput.type = "text";
instance++;
document.body.insertBefore(document.createElement("BR"), element);
document.body.insertBefore(newInput, element);
}
First name:
Last name: