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>
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)")
*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!