Modify ↓
Ticket #7692 (closed bug: invalid)
selector :gt does not work on table
| Reported by: | edwin74@… | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.6 |
| Component: | unfiled | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
when give a class to a <tr> and want to exclude each first d in a row the following code does only disabled the first td in the first row:
$j('.getform td:gt(0)')
<tr class="getform">
<td></td>
<td></td> </tr> <tr class="getform">this first td is clickable but schould not be clickable
<td></td>
<td></td> </tr>
This gies the desired result:
$j('.getform td:not(:first-child)')
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case! After checking your report I came to the conclusion that this isn't a bug but a misunderstanding on the behavior of :gt(0).
The described behavior of :gt(index) is
It is important to understand that the matched set of elements is determined by the selector .getform td which yields all td's (in your case 4 td's) and then :gt(0) is applied which excludes the first td in the set and returns the other 3. The :gt(index) operates on the matched elements not on the relative "position" of the element inside it's parent.
To achieve what you want the solution given by you .getform td:not(:first-child) is the right way to go.
For completeness here another test case which uses a :nth-child(an+b) selector to achieve the same result.