如何使用循环生成15个输入并运行一次? [英] How to generate 15 inputs with loop for and run just once?
本文介绍了如何使用循环生成15个输入并运行一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用循环生成15个输入,
每个输入都有自己的id并且只运行一次?
how to generate 15 inputs with loop for, every input with their own "id" and run just once?
<input type="button" onclick="generate()">
<script>
function generate(){
for(var i=0; i < 15; i++) {
}
}
推荐答案
这是你在寻找什么?
for(var i=0 ; i<15;i++)
{
var input = document.createElement('input');
input .setAttribute('id',"input"+i);
document.getElementById("formName").appendChild(input);
}
这篇关于如何使用循环生成15个输入并运行一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文