![]() |
VOOZH | about |
The last() function is an inbuilt function in jQuery which is used to find the last element of the specified elements.
Syntax:
$(selector).last()
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.
JavaScript code to show the working of this function:
Example 1:
In this code the background-color of the last "p"element get changed.
Output:
👁 ImageExample 2:
In the above example the last elements with class "main" get highlighted.
Output:
👁 Image