Home > Web Front-end > JS Tutorial > Solve the problem of Jquery :lt(index) and :gt(index)) selectors

Solve the problem of Jquery :lt(index) and :gt(index)) selectors

黄舟
Release: 2017-06-23 10:44:08
Original
1493 people have browsed it

Test question:

$(document).ready(function(){
    $("tr:gt(0):lt(2)").css("background-color","#B2E0FF");
});
Copy after login

If the positions of gt() and lt() are swapped, the displayed results will be different! ~
Putting lt() in front is the result I want, but putting gt() in front is a pitfall.
The following code comes from w3cshool. My project jquery1.8.2.js also has similar problems.
Looking forward to the master explaining the reason for this. .




   
  

Welcome to My Web Page

Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing
4 Obama Barack Pennsylvania Avenue Washington
Copy after login

:gt(n) All elements with serial numbers greater than n
:lt(n) All elements with serial numbers less than n
:gt(0):lt(2) Represents numbers 1 and 2 Element
:lt(2):gt(0) means element No. 1

Yes, :gt(0):lt(2) can be understood as 0< index <= 2, :lt (2): gt(0) is 0< index < 2; the jquery manual does not introduce this usage. Is this a bug?

a,b,c,d,e
:gt(0) gets
b,c,d,e
:lt(2) gets
b,c

The selector filters down step by step, and each step of filtering is performed on the results of the previous step

a,b,c,d,e
:gt(0) Get
b,c,d,e
:lt(2) gets
b,c

The selector is filtered step by step, and each step of filtering is based on the results of the previous step. ongoing

The above is the detailed content of Solve the problem of Jquery :lt(index) and :gt(index)) selectors. 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