: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