如何创建<input type="text"/>动态地 [英] How to create <input type=“text”/> dynamically
本文介绍了如何创建<input type="text"/>动态地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的网络表单中动态创建输入类型文本.更具体地说,我有一个文本字段,用户可以在其中输入所需文本字段的数量;我希望以相同的形式动态生成文本字段.
I want to create an input type text in my web form dynamically. More specifically, I have a textfield where the user enters the number of desired text fields; I want the text fields to be generated dynamically in the same form.
我该怎么做?
推荐答案
使用 JavaScript:
With JavaScript:
var input = document.createElement("input");
input.type = "text";
input.className = "css-class-name"; // set the CSS class
container.appendChild(input); // put it into the DOM
这篇关于如何创建<input type="text"/>动态地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文