Yes nice explanation, thank you.

On 2/20/07, Jonathan Chaffer <[EMAIL PROTECTED]> wrote:

On Feb 20, 2007, at 13:21 , Jake McGraw wrote:

Thanks Blair, that works, here I was thinking filter() "filtered out" all
matched elements, I must be getting dyslexia. But that still doesn't answer
why find() won't work on jQuery objects selected using classname.


It does. The difference between .filter() and .find() is that the former
searches through the matched elements, while the latter searches through the
*descendants* of the elements. I believe that when you say:

> So, my question is, if find() will operate on elements of the same
> level using element name or id ($("li").find(".group") returns all
> li.group) why won't it work on elements of the same level when using
> only class names ($(".group").find(".us") returns nothing)?


you must have seen a result that was coincidentally what you expected.
Given the HTML:
  <div class="foo bar">Test</div>

$('div.foo') selects the element
$('div').filter('.foo') selects the element
$('div').find('.foo') does not select the element

similarly,
$('.foo.bar') selects the element
$('.foo').filter('.bar') selects the element
$('.foo').find('.bar') does not select the element

If it appeared that .find() was selecting elements already in the matched
set, this is because an ancestor of the elements was already in the matched
set.

--

Jonathan Chaffer

Technology Officer, Structure Interactive

(616) 364-7423    http://www.structureinteractive.com/




_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to