Skip to main content

Bug Tracker

Side navigation

#4592 closed bug (worksforme)

Opened April 26, 2009 11:44PM UTC

Closed May 04, 2009 12:37AM UTC

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.

Attachments (0)
Change History (1)

Changed May 04, 2009 12:37AM UTC by dmethvin comment:1

resolution: → worksforme
status: newclosed

The first case shouldn't be surprising since the docs say

"Matches a single element by its index."

The selector

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

As the docs say, the

selector is 0-based but the
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.