:last Selector

Selects the last matched element.

.last()

As of jQuery 3.4, the :last pseudo-class is deprecated. Remove it from your selectors and filter the results later using .last().

Note that :last selects a single element by filtering the current jQuery collection and matching the last element within it.

Finds the last table row.

JS
<table>
  <tr>
    <td>First Row</td>
  </tr>
  <tr>
    <td>Middle Row</td>
  </tr>
  <tr>
    <td>Last Row</td>
  </tr>
</table>
HTML
$("tr").last().css({ backgroundColor: "yellow", fontWeight: "bolder" });
DEMO

Looking for a Web Developer?

👋

Hi! I'm Basti, author of this site. If you are looking for a web developer with 15+ years of experience, holla at me!

Be it the good 'ol jQuery, vanilla JS or modern frameworks like Vue and Svelte, front- or backend, I can help you.

Just write me at jobs@jqapi.com :)