.last() Returns: jQuery
Description: Reduce the set of matched elements to the final one in the set.
-
version added: 1.4.last()
-
This method does not accept any arguments.
-
Given a jQuery object that represents a set of DOM elements, the .last()
method constructs a new jQuery object from the last element in that set.
Consider a page with a simple list on it:
1
2
3
4
5
6
7
|
|
We can apply this method to the set of list items:
1
|
|
The result of this call is a red background for the final item.
Example:
Highlight the last span in a paragraph.
1
2
3
4
5
6
7
8
9
10
11
12
|
|