:first, :lastの使い方

A1
A2
A3

$("tr:first").css("background-color", "red");
$("tr:last").css("background-color", "yellow");

<table border="1">
  <tr><td>A1</td></tr>
  <tr><td>A2</td></tr>
  <tr><td>A3</td></tr>
</table>