jQuery - Why doesn't combining has() and gt() work in some cases?

Posted by KatieK on Stack Overflow See other posts from Stack Overflow or by KatieK
Published on 2010-05-03T20:59:15Z Indexed on 2010/05/03 21:08 UTC
Read the original article Hit count: 158

Filed under:
|

I wanted to select any ul which contains more than 3 lis.

This code worked with the 1.2.6 jQuery library:

$("ul:has(li:gt(2))")  
.each( function() {  
$(this).css("border", "solid red 1px");  
}); 

But not 1.3.2 or 1.4.2.

This code worked with the 1.4.2 jQuery library:

$('ul').has('li:nth-child(3)').css('border', 'solid red 1px'); 

But not v1.2.6.

Why does each version work with one library version, but not the other? Am I encountering some kind of bug, or am I doing something wrong?

Any help understanding , or differences to be aware of between different versions of the jQuery libraries, would be much appreciated. Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery