Jquery实现表格添加,删除一行
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-3.3.1.min.js" ></script>
<script>
var i = 2 ;
$(function(){
$("#putid").click(function(){
i++;
$("table").append("<tr> <td>"+i+"</td> <td>小明"+i+"</td> <td><input type='button' value='删除'></td> </tr>")
})
})
</script>
</head>
<body>
<input type="button" value="添加行" id="putid">
<table border="1" id = "tid">
<tr>
<td>用户编号</td>
<td>用户姓名</td>
<td>操作</td>
</tr>
<tr>
<td>1</td>
<td>小明1</td>
<td><input type="button" value="删除"></td>
</tr>
<tr>
<td>2</td>
<td>小明2</td>
<td><input type="button" value="删除"></td>
</tr>
</table>
</body>
</html>