<head>
<script type="text/javascript" src="D:/lll/jquery-3.3.1.min.js"></script>
<script>
//添加一行
function add_tr(obj) {
var tr = $(obj).parent().parent();
tr.after(tr.clone());
}
function del_tr(obj) {
$(obj).parent().parent().remove();
}
</script>
</head>
<body>
<form>
<table class="table">
<tr>
<td><input type='text' name='name' /></td>
<td><input type='text' name='age' /></td>
<td><input type='text' name='sex' /></td>
<td>
<select>
<option>aa</option>
</select>
</td>
<td>
<button class="button" "add_tr(this)”>添加</button>
<button class="button" "del_tr(this)">删除</button>
</td>
</tr>
</table>
</form>
</body>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<form role="form-group" style="display: inherit;width: 460px;margin-top: 20px;margin-left: 20px" id="tb">
帐号: <input type="text"
placeholder="请输入帐号">
密码: <input type="password"
placeholder="请输入密码">
<img src="add.png" alt="" "add()" style="width:30px">
</form>
<div class="btn btn-default" style="margin-top: 20px;margin-left: 200px">提交</div>
</body>
</html>
<script>
function add() {
var form = document.createElement("form-group");
form.id = new Date().getTime();
form.innerHTML = "<form role='form-group' style='display: inherit;width: 550px'>" +
"帐号: " + "<input name="name" placeholder='请输入帐号'/>" +
" 密码: <input placeholder='请输入密码'/>" +
"<img src='del.png''del(this)' style='width:30px'></form>";
document.getElementById("tb").appendChild(form);
}
function del(obj) {
var formID = obj.parentNode.parentNode.id;
var form = document.getElementById(formID);
document.getElementById("tb").removeChild(form);
}
</script>
//后台获得数据
String[] names = request.getParameterValues("name") //因为动态添加的数据name都一样 所以获得的是一个数组