javascript - 动态表单框

标签 javascript php html

陷入困境!

我有一个表格,用于输入用户想去的不同城市。

我有一个表单框和一个提交按钮。

现在我希望我的用户输入他喜欢的多个城市,为此他必须单击链接 Add 1 more city并且应该会出现另一个表单框。

如何在 HTML 中执行此类任务

最佳答案

这是一个很好的方法:

<div id="inputBoxes"> 
    <input />
</div>

<button type="button">Add more</button>

$('button').click(function() {
    $('#inputBoxes').append('<input>');
});

希望对你有帮助

佐肯17

$('button').click(function() {
  $('#inputBoxes').append('<input>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>


<div id="inputBoxes"> 
    <input />
</div>

<button type="button">Add more</button>

关于javascript - 动态表单框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33555170/

相关文章:

html - 如何在顶部菜单上使背景 100%

javascript - <IMG> 不保持内联 - Javascript

javascript - 如何在ngFor中实现固定div列?

javascript - 捕获 'Origin is not allowed by Access-Control-Allow-Origin' 错误

php - 生成Excel文件,但不保存到服务器

php - mysql 连接 symfony + docker

javascript - *ngIf 内的 viewChild 产生 undefined reference

php - 论坛帖子表应该使用 MyISAM 还是 InnoDB

javascript - 使用 pdf.js 将 html 转换为 pdf

html - 为什么 TD 宽度不起作用或未遵循?