In the docs, where 'expr' as stated as being either a 'string' or an
'expression' it means that it is a selector expression, ie. a string
that would be acceptable as a selector in $("selector").
In all the examples you have given - filter, find, parent, etc - the
expected argument is a selector expression (and possibly a function
but that's beside the point).
The exception you found for find() is simply the code being kind(?) to
you. Running find(DOMelement) could be considered a waste of time
because you're trying to find() something you already have. So the
code actually doesn't do a find() at all, it simply returns (in a
jQuery object) the element you supplied, regardless of whether or not
that element was actually within the context of the initial jQuery
object.
Eg.
var b = $('body');
$('ul li').find(b[0]) == b;

(This may be considered strange behaviour, seeing as 'body' is well
outside the context of 'ul li', but then this is actually a misuse of
find() and so shouldn't be particularly surprising.)

There is nothing strange about not() and filter(). They both accept a
selector expression; however, not() will *also* accept an element, or
array thereof, whereas filter() won't (but will accept a function
instead).
Knocking a known element out of a set using not(DOMelement) is
reasonable; reducing a set to a known element using filter(DOMelement)
is not - the result is part of query!


On May 8, 3:21 pm, "Dan G. Switzer, II" <[EMAIL PROTECTED]>
wrote:
> Karl,
>
> >Yeah, it's also strange that while this doesn't work:
> >     $("body > ul > li").filter($li[0]);
>
> >this does:
> >    $("body > ul > li").not($li[0]);
>
> >I'm a little lost by your parents example, though. Not sure exactly
> >what you're trying to get (esp. since you don't show where you've
> >declared $el and $parent.
>
> Let's say you have:
>
> <ul>
>         <li id="1">
>                 Parent 1
>                 <ul>
>                         <li id="2">
>                                 Child 1
>                         </li>
>                 </ul>
>         </li>
> </ul>
>
> What I want to do is see if "Child 1" has "Parent 1" somewhere in it's
> parent path. I don't really care if "Child 1" would be a child of a child of
> a child, just that at some point "Parent 1" was actually in the parent path.
>
> So, I would expect to be able to do:
>
> var $p = $("#1");
> $("#2").parents($p);
>
> Well this does work:
> $("#2").parents("#1");
>
> It doesn't work for me, since the actually "expression" I need to check
> against a jQuery object that can't be reliable queried through a pure
> CSS-style selector.
>
> >couldn't you do something like
> >$el.parent() ?
> >or $el.parent('.someclass') ?
> >or $el.parents('.someclass:first') ?
>
> >(just using class in the parents filter because not sure what you're
> >after).
>
> As I stated, using a CSS expression doesn't work for me because I'm actually
> checking to see if another jQuery object is somewhere in the parent's tree.
>
> -Dan

Reply via email to