Skip to main content

Bug Tracker

Side navigation

#3407 closed bug (invalid)

Opened September 24, 2008 11:17PM UTC

Closed February 07, 2009 02:39PM UTC

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.

Attachments (0)
Change History (3)

Changed September 25, 2008 01:43AM UTC by scott.gonzal comment:1

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

Changed October 08, 2008 05:14PM UTC by greggreenhaw comment:2

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.

Changed February 07, 2009 02:39PM UTC by dmethvin comment:3

resolution: → invalid
status: reopenedclosed

Scott's right. Perhaps you wanted something like