Starting Situation
These two commands should be equivalent.
jQuery('a').filter(':contains(about)');
and
jQuery.find('a').filter(':contains(about)');
Problem
In fact, the first command performs well, whereas the second throws the following exception:
TypeError: :contains(about) is not a function
Why ist that? Shouldn’t jQuery('a') and jQuery.find('a') return the same object? If not, what’s the difference?
Explanation
I am dynamically building a JQuery command chain (part of a JQuery Java Wrapper which is used in my project Abmash). Therefore, i prefer a chain of methods like jQuery.find('a').filter(':contains(about)').
jQuery.find('a')returns a array (Array.filter()takes a function as argument.)jQuery('a')returns a jQuery-array-like-Object