English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The last() method returns the last element of the selected elements.
To return the first element, usefirst()Method.
$("selector").last()
Highlight the last paragraph:
$("document").ready(function(){ $("p").last().css("background", "coral"); });Test and See‹/›
Highlight the last paragraph within the last DIV element:
$("document").ready(function(){ $("div p").last().css("background", "coral"); });Test and See‹/›
Highlight the last unordered list:
$("document").ready(function(){ $("ul").last().css("background", "coral"); });Test and See‹/›