<table>
<tr>
<td>Spoon</td>
<td><button>Delete</button></td>
</tr>
<tr>
<td>Fork</td>
<td><button>Delete</button></td>
</tr>
<tr>
<td>Knife</td>
<td><button>Delete</button></td>
</tr>
<tr>
<td>Plate</td>
<td><button>Delete</button></td>
</tr>
</table>
let buttons = document.querySelectorAll("table button");
buttons.forEach((element) =>
element.addEventListener("click", function () {
this.parentElement.parentElement.remove();
})
);
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.