JQuery index and selectors: lt and: gt

How do the lt and gt selectors work? Same as order? (if they are both in the same selector)

I need two answers to this question.

1) The result of the next line should NOT ALWAYS be 0 ??? I ask that the td index be greater than 3 AND lower than 2. There is an index that can be: ix> 3 and ix <2 at the same time!

$("tr").find("td:gt(3):lt(2)").length

2) It turns out that when I change the order of the gt and lt selectors, it starts to work well. The result of the following line: 0.

$("tr").find("td:lt(2):gt(3)").length

Is the order of the selectors really independent of the result?

It looks like selector lt doesn't work if it's after gt or something like that!

Additional Information:

  • You can watch it here: http://jsfiddle.net/YQtRh/
  • For those who are wondering what is the result of the first line of js, is 1.
  • , td, , (.text() == 4)

!

+5
3

, jQuery , . , :gt(3):lt(2) " 3, 2". td:lt(2):gt(3) , .


:

<table>
    <tr>
        <td>0</td>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
    </tr>
</table>

:gt(3) , 3. , ( Chrome):

[<td>​4​</td>​]

:lt(2) , , , 0, 2.

:lt(2) :

[<td>​0​</td>​, <td>​1​</td>​]

:gt(3) , , , 0 1 , 3.

+5

, .

1) , 5 .

  • > 3: 1 .
  • < 2: 1 , 4 0.

2)

  • < 2: 2 .
  • > 3 : 0.
+1

   $("tr").find("td").slice(startindex,endindex)

Sumesh

+1

All Articles