<html lang="en">
<head>
<title>jQuery Remove Entire Table Rows Except First and Second</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<style>
table.myTableDeletefsall{
border-collapse:collapse;
}
table.myTableDeletefsall th, table.myTableDeletefsall td{
border:1px solid #ccc;
padding:5px;
}
</style>
<script>
$(document).ready(function(){
$('.btndeletefsall').click(function(){
$(".myTableDeletefsall tr").slice(2).remove();
});
});
</script>
</head>
<body>
<h2>jQuery Remove Entire Table Rows Except First and Second</h2>
<button type="button" class="btndeletefsall">Delete All Rows Except First and Second</button><br><br>
<table class="myTableDeletefsall">
<thead>
<tr>
<th>Team Name</th>
<th>Crickert Name</th>
<th>Score</th>
</tr>
</thead>
<tbody>
<tr>
<td>West Indies</td>
<td>Chris Gayle</td>
<td>195</td>
</tr>
<tr>
<td>India</td>
<td>Virat Kohli</td>
<td>124</td>
</tr>
<tr>
<td>Australia</td>
<td>David Warner</td>
<td>167</td>
</tr>
<tr>
<td>South Africa</td>
<td>AB De Villier's</td>
<td>185</td>
</tr>
</tbody>
</table>
</body>
</html>