console
$(function () {
$('input:button').click(function(){
let num = getNum()
let name = $("input:eq(0)").val()
let cls = $("input:eq(1)").val()
let score = $("input:eq(2)").val()
let node = $('<tr><td> '+num+'</td><td>' + name + '</td><td>'
+ cls + '</td><td>' + score + '</td><td><button onclick= "del(this)">删除</button></td></tr>"')
$('tbody'). append(node)
})
})
function del(obj){
console. log($(obj). parent(). parent())
$(obj).parent() . parent(). remove()
}
function getNum(){
return $('tbody' ). children(). length+1
}
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<form>
<input placeholder="姓名"/>
<input placeholder="班级"/>
<input placeholder="成绩"/>
<input type="button" value="添加"/>
</form>
<table border=1 >
<thead>
<tr>
<th>编号</th>
<th>姓名</th>
<th>班级</th>
<th>成绩</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>