tags:

views:

88

answers:

3

A follow-up to the comment I just posted here... I ran this in Firebug:

var l = []; for(f in $('div')){l.push(f);}; l.sort(); alert(l.join("\n"));

just to make sure I wasn't going crazy, and "contains" is not, in fact, a method of the jQuery wrapped set. But the jquery docs page says it is. What gives? Was there a "contains" method that got deprecated? Is it new, and the version I'm testing with (1.2.1) doesn't have it yet? Is there a better way to find this information than asking on SO?

+3  A: 

It was deprecated on 1.2, and completely replaced by the filter expression on 1.3.

More info:

CMS
+1  A: 

It looks like in jQuery 1.1.3.1, contains was a supported function, along with eq, lt, and gt, as an alias for a call to filter() using those CSS filters. As of jQuery 1.2, the method no longer is present in the code.

So it would seem the documentation is for the previous version, that method was indeed removed from jQuery. Note that in the table of contents for Traversing, it's not listed. Of course, using filter() instead will work as it always has.

Adam Bellaire
I'd submit a ticket to their bugtrack to have deprecated methods marked as "deprecated" in the docs, but I can't be arsed to create an account on their website just to do that. I guess nobody else can, either :(
Coderer
A: 

Take a look on one of the powerful features of jQuery, the traversal methods.

http://www.jaftalks.com/Home/Show/Introduction-to-JQuery-Traversal-Methods

JafTalks