Skip to main content

Bug Tracker

Side navigation

#6543 closed bug (worksforme)

Opened May 07, 2010 06:20AM UTC

Closed May 07, 2010 05:40PM UTC

:visible and :nth-child selector

Reported by: coplas Owned by:
Priority: Milestone: 1.4.3
Component: core Version: 1.4.2
Keywords: visible nth-child Cc:
Blocked by: Blocking:
Description

there is a problem with not visible elements

(in my case TRs)

".tab tr:visible:even"

works as expected,

but

"tr:visible:nth-child(2n-1)"

not, it probably matches not only visible but all elements.

example:

http://jsbin.com/ezocu

$(function() {

$("#t1 tr:eq(3)").hide();

$("#t2 tr:eq(3)").hide();

$(".tab tr:visible:even").addClass("even");

$(".tab tr:visible:nth-child(even)").addClass("even2");

});

Attachments (0)
Change History (1)

Changed May 07, 2010 05:40PM UTC by dmethvin comment:1

resolution: → worksforme
status: newclosed

Note that

:eq
and
:even
are 0-based and apply to the entire collection (with tr elements crossing two tables in this example ) whereas
:nth-child
is 1-based and applies to the sibling order regardless of visibility. Whether the tr is visible or not does not affect the
:nth-child()
selector; it is still that child whether it is visible or not. When I look at the markup in Firebug it doesn't seem that the hidden elements ever have even2 applied to them so it seems like the
:visible:nth-child()
combination worked properly.