Bug Tracker

Opened 14 years ago

Closed 14 years ago

#4592 closed bug (worksforme)

Invalid element by specified index

Reported by: DelMadman Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: eq, nt-child Cc:
Blocked by: Blocking:


I have a table with 15 columns, 3rd column is invisible with css property 'display:none'. The task is to get 13th cell in all rows.

At runtime I know column index and tryed two queries:

  1. $("#mytable").find("tr td:eq(13)")
  2. $("#mytable").find("tr td:nth-child(13)")

The first query returns certain cell but only from the first row. Against the second query returns invalid cells (12th in my way), but in all rows. I think the reason is in the 3rd invislible column.

As a user I think that both queries should be equals, I mean they should return 13th cell in row no matter it visible or not.

Change History (1)

comment:1 Changed 14 years ago by dmethvin

Resolution: worksforme
Status: newclosed

The first case shouldn't be surprising since the docs say :eq "Matches a single element by its index."


The selector "tr td:eq(13)" returns all td elements that are descendants of a tr element (all of them) and selects the 13th element.

As the docs say, the :eq selector is 0-based but the :nth-child selector is 1-based. Does that explain the difference you are seeing in counting cells? You didn't provide a test case so it's hard to know if things are working as they should.

It's best to ask about these things on the forums to be sure they're really bugs before opening a ticket. I'll close the ticket for now, but if you have a test case that shows things aren't working as documented just reopen the ticket and attach the file.

Note: See TracTickets for help on using tickets.