开发者

What happened to the jQuery "contains" traversal method?

开发者 https://www.devze.com 2022-12-12 12:53 出处:网络
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\"));

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 开发者_如何学Gogoing 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?


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

More info:

  • Removed Functionality


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号