jQuery :lt selector

Example

Select the first 2 <tr> elements:

$("tr:lt(2)")

Try it yourself

Definition and usage

:lt selector selects elements with an index value less than the specified value.

The index value starts from 0.

It is often used with other elements/selectors to select elements before a specific index in a specified group (as shown in the example above).

Syntax

$(":lt(index)")
Parameter Description
index

Required. Specifies the element to be selected.

It will select elements with an index value less than the specified number.

Tips and comments

Tip:Please use :gt selectorTo select elements with an index value greater than the specified number.