1 回答
TA贡献1797条经验 获得超4个赞
您可以创建createElement("form");控件并将其添加到表单中form.appendChild(mile2Form);
也是一个很好的约定,您应该在</body>标记之前移动脚本块
let addButton = function() {
var form = document.createElement("form");
form.setAttribute('method',"post");
form.setAttribute('action',"#");
let mile2Form = document.createElement('input');
mile2Form.setAttribute('type', 'time');
form.appendChild(mile2Form);
document.body.appendChild(form);
}
let addButton = function() {
var form = document.createElement("form");
form.setAttribute('method',"post");
form.setAttribute('action',"#");
let mile2Form = document.createElement('input');
mile2Form.setAttribute('type', 'time');
form.appendChild(mile2Form);
document.body.appendChild(form);
}
<section>
<button class= "addButton" onclick="addButton()">Add Another Time</button>
</section>
添加回答
举报