Bug Tracker

Opened 14 years ago

Closed 14 years ago

#3407 closed bug (invalid)

Multiple :gr do not work as expected

Reported by: greggreenhaw Owned by:
Priority: major Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: gt:, selctors Cc:
Blocked by: Blocking:


running this: $('table tr:gt(1) td:gt(2)').css('background-color','white');

on a table will skip on the first 2 columns on the first row and not on each additional row.

Change History (3)

comment:1 Changed 14 years ago by scott.gonzal

Resolution: worksforme
Status: newclosed

This is the correct behavior. The selector says find all tables, then fine all rows, and limit to everything after the first row, then find all data cells and limit to everything after the first two cells.

To accomplish what you want, you need to do:

$('table').each(function() {
    $(this).find('tr:gt(1)').each(function() {
        $(this).find('td:gt(2)').css('background-color', 'white');

comment:2 Changed 14 years ago by greggreenhaw

Resolution: worksforme
Status: closedreopened

I disagree since its in the selector, I think it should scoped in the context of the parent "tr" selector, thus for each row greater than 1 cells greater than 2, for each row. Otherwise I would just do an array _slice or someting or a simple filter as a nested function.

comment:3 Changed 14 years ago by dmethvin

Resolution: invalid
Status: reopenedclosed

Scott's right. Perhaps you wanted something like :not(:first-child) instead?

Note: See TracTickets for help on using tickets.