Home > Web Front-end > JS Tutorial > How to get the specified index value in jquery

How to get the specified index value in jquery

亚连
Release: 2018-06-09 15:38:41
Original
1708 people have browsed it

Below I will share with you a jquery method for obtaining a list of index values ​​within a certain range. It has a good reference value and I hope it will be helpful to everyone.

is as follows:

<ul>
 <li>1</li>
 <li>2</li>
 <li>3</li>
 <li>4</li>
 <li>5</li>
 <li>6</li>
 <li>7</li>
 <li>8</li>
</ul>
Copy after login

jquery selector:

eq(index) match The index element in the list (index starts from 0)

gt(index) matches the element whose list index is greater than index

lt(index) matches the element whose list index is less than index

Get the li from 2nd to 5th index:

$("ul li:lt(5):gt(2)")
Copy after login

*Note:Here:lt(5):gt( 2) The order cannot be changed, it must be lt first and gt last.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to implement the Baidu search interface in JS

How to implement the double-color ball function in JS

How to achieve snow animation effect in jQuery

The above is the detailed content of How to get the specified index value in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template