Bug Tracker

Modify

Ticket #7692 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

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

comment:1 Changed 2 years ago by jitter

  • Status changed from new to closed
  • Resolution set to invalid

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

Select all elements at an index greater than index within the matched set.

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.