如何创建< input type =“text”/>动态 [英] How to create <input type=“text”/> dynamically
本文介绍了如何创建< input type =“text”/>动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想动态地在我的web表单中创建一个输入类型的文本。更具体地说,我有一个文本字段,用户输入所需文本字段的数量;我想要以相同的形式动态生成文本字段。
我该怎么做? 使用JavaScript: / p>
var input = document.createElement(input);
input.type =text;
input.className =css-class-name; //设置CSS类
container.appendChild(input); //把它放到DOM
中
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.
How do I do that?
解决方案
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屋!
查看全文