Javascript?:如何动态地将文本输入/表单字段添加到HTML表单? [英] Javascript?:How to dynamically add text inputs/form fields to a HTML form?
本文介绍了Javascript?:如何动态地将文本输入/表单字段添加到HTML表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在构建一个包含输入列表的Web表单。到目前为止,这么好。
但是,我如何添加一个链接/按钮来添加另外5个字段到列表中。例如:
< input>
< input>
< input>
< input>
< a href =onclick =>再添加10个字段< / a>
我在这个网站上看了很多类似的q,但似乎都没有描述如何添加多个字段。
感谢您的帮助,
Harley
<编辑编辑:感谢大家的帮助,看起来像jquery追加是要走的路。
但是我很欣赏不使用jquery的替代方案。
解决方案
$(#anyDiv)。html('< input id =id1/>');
....
$(#anyDiv)。append('< input id =id2/>');
I am building a web form where there is a list of inputs. So far, so good.
However, how can I add a link/button to add say another 5 fields to the list. eg:
<input>
<input>
<input>
<input>
<a href="" onclick="">Add 10 more fields</a>
I have looked through many similar q's on this site, however none seem to describe how to add multiple fields.
Thanks for any help,
Harley
EDIT: Thanks all for help, looks like jquery append is the way to go. However I appreciate the alternative that does not use jquery.
解决方案
$("#anyDiv").html('<input id="id1"/>');
....
$("#anyDiv").append('<input id="id2"/>');
这篇关于Javascript?:如何动态地将文本输入/表单字段添加到HTML表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文