<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<table width="500" border=1>
<tr>
<th>序号</th>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th>操作</th>
</tr>
<tr>
<td>1</td>
<td>张三</td>
<td>12</td>
<td>男</td>
<td>删除</td>
</tr>
<tr>
<td>2</td>
<td>李四</td>
<td>13</td>
<td>女</td>
<td>删除</td>
</tr>
<tr>
<td>3</td>
<td>王五</td>
<td>15</td>
<td>女</td>
<td>删除</td>
</tr>
</table>
</body>
<script>
document.querySelector('table').onclick = function(){
// 获取精准的目标元素
var target = window.event.target
// 判断是否是删除的td
if(target.innerText === '删除'){
// console.log(target);
// console.log(document.querySelector('table'), target.parentElement);
target.parentElement.parentElement.removeChild(target.parentElement)
}
}
</script>
</html>