In jquery, you can use the ":lt()" selector to select the first few elements. This selector is used to select elements whose index value is less than the specified number. This selector is often used together with other selectors. You can select the elements before a specific sequence number in the specified combination, and the syntax is "$(":lt(index)")".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
:lt() selector selects elements whose index value is less than the specified number.
index values start from 0.
The most common usage: used with other selectors to select elements before a specific sequence number in the specified combination (such as the example above).
On the contrary, you can use :gt selector to select elements whose index value is greater than the specified number.
Syntax
$(":lt(index)")
index Required. Specifies the elements to be selected. Elements whose index value is less than the specified number will be selected.
The example is as follows:
123 欢迎来到我的主页
序号 | 站点名 | 网址 |
---|---|---|
1 | google.com | |
2 | PHP | php.cn |
3 | Taobao | taobao.com |
4 | Baidu | baidu.com |
5 | Sina | sina.com.cn |
6 | facebook.com | |
7 | twitter.com | |
8 | youtube | youtube.com |
Output result:
Related video tutorial recommendation:jQuery video tutorial
The above is the detailed content of How to select the first few elements in jquery. For more information, please follow other related articles on the PHP Chinese website!