Modify ↓
Ticket #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: | |
| Blocking: | Blocked by: |
Description
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
comment:1 Changed 5 years ago by scott.gonzal
- Status changed from new to closed
- Resolution set to worksforme
comment:2 Changed 5 years ago by greggreenhaw
- Status changed from closed to reopened
- Resolution worksforme deleted
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.
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.

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'); }); });