Skip to main content

Bug Tracker

Side navigation

#6723 closed bug (duplicate)

Opened June 25, 2010 03:01PM UTC

Closed March 31, 2011 03:24AM UTC

Last modified March 31, 2011 03:24AM UTC

:has fails in combination with :gt

Reported by: acdha Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.4.4rc
Keywords: Cc:
Blocked by: Blocking:
Description

Assuming a list like:

<ul><li></li><li></li><li></li></ul>

expressions like jQuery("ul:has(li:gt(1)") will fail to match anything.

I was going to write a test-case but there's a nice one here which I couldn't find referenced in the bug tracker:

http://kruisit.nl/jquerybugs/?version=nightly

There is a workaround:

jQuery("ul").has("li:gt(1)")

or

jQuery("li:gt(1)").parent()

Attachments (0)
Change History (5)

Changed June 29, 2010 04:20PM UTC by acdha comment:1

Note for anyone else trying: the first workaround with .has() is not correct as it will match as long as there are more than the :gt() count elements anywhere on the entire page, not just under the selected <ul>. To get this to work reliably with jQuery 1.4.2 requires something like this:

jQuery("ul").each(function (i) { 
    if ($(this).children("li").length > 10) { 
        … 
    }
});

Changed November 01, 2010 08:36PM UTC by rwaldron comment:2

milestone: 1.4.3
priority: → low
status: newopen
version: 1.4.21.4.4rc

Changed March 30, 2011 08:39PM UTC by danheberden comment:3

milestone: → 1.next

Changed March 31, 2011 03:24AM UTC by danheberden comment:4

resolution: → duplicate
status: openclosed

Changed March 31, 2011 03:24AM UTC by danheberden comment:5

Duplicate of #8720.