Delete table row when user click on row
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script>
$(document).ready(function() {
$('.deleteRowButton').click(function(){
$(this).parents('tr').first().remove();
})
});
</script>
</head>
<body>
<table>
<tr>
<td><a class="deleteRowButton">Test1</a></td>
</tr>
<tr>
<td><a class="deleteRowButton">Test2</a></td>
</tr>
<tr>
<td><a class="deleteRowButton">Test3</a></td>
</tr>
</table>
</body>
</html>
Most Helpful This Week
How to define Global Variable in JavaScript?
JavaScript simple alert on Click
JavaScript sort multi dimensional array on specific columns
How to the length of the longest word in the provided sentence?
How to scroll page to 1000px from top on page load using jQuery?
How to check a variable is undefined in JavaScript?