English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:lt() selector selects all elements with index numbers less than the specified number.
Index numbers start from 0, so the index number of the first element is 0 (not1)
It is usually used with another selector to select the first element in a group (as shown in the following example).
Use:gtThe selector selects element index numbers greater than the specified number.
$":lt(index)")
Select elements with index numbers less than5of all <tr> elements:
$("document").ready(function(){ $("tr:lt(5)").css("background", "coral"); });Test See‹/›
Select all <p> elements within the DIV whose index number is less than3:
$("document").ready(function(){ $("div p:lt(3)").css("background", "coral"); });Test See‹/›
Parameter | Description |
---|---|
index | Specify an index less than the selected number |