The last() function is an inbuilt function in jQuery which is used to find the last element of the specified elements.
Here selector is the selected elements.
Parameters: It does not accept any parameter.
Return value: It returns the last element out of the selected elements.
In this code the background-color of the last “p” element get changed.
In the above example the last elements with class “main” get highlighted.
- jQuery | :last Selector
- jQuery | :last-of-type Selector
- jQuery | :nth-last-child() Selector
- jQuery | :last-child Selector
- jQuery | :nth-last-of-type() Selector
- How to select the last row of a table using jQuery ?
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- Underscore.js | _.last() with Examples
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
- jQuery | offset() with Examples
- jQuery | children() with Examples
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- jQuery | focusin() with Examples
- jQuery | Animation, Slide methods with Examples
- jQuery | change() with Examples
- jQuery | filter() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.