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