← Back to Index

.last()

Reduce the set of matched elements to the final one in the set.

Examples

1. Get last element

// <li>A</li><li>B</li>
$('li').last().addClass('last-item');

Result

<li>A</li>
<li class="last-item">B</li>

Details

Equivalent to .eq(-1).

Returns: A new SR object.