On Jul 2, 2:11 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> On Jul 2, 2008, at 7:57 AM, [rob desbois] wrote:
>
>
>
>
>
> > Hi, have a feeling this may be a silly question but here goes..
>
> > Test output from Firebug's console is below to explain my issue.
>
> > I select an array of divs by their parent:
> >>>> divs = $("#sidebar > div").get()
> > [div#sidebar-search-tabcont, div#sidebar-events-tabcont]
>
> > I then want to find a particular one:
> >>>> $("div", divs)
> > Object length=0 prevObject=Object jquery=1.2.6
>
> > Given that the 'expr' parameter to $(...) contains an array of divs,
> > why is using the selector "div" not returning anything from that?? Am
> > I misunderstanding expr?
>
> > Confused...
> > --rob
>
> Hi Rob,
>
> Your selector $('div', divs) is looking for all div elements contained  
> in any of the divs stored in your variable. So, it's like doing $
> (divs).find('div') . I think you may have been expecting it to work  
> like $(divs).filter('div')? Do any of the divs selected by $("#sidebar  
>  > div").get() have child divs? If not, the second selector shouldn't  
> be returning anything.
>
> Hope that makes sense
>
> --Karl
>
> ____________
> Karl Swedbergwww.englishrules.comwww.learningjquery.com

Aha! Yes it does.

Seems a bit odd though, the array (or jQuery/DOM object if so) *does*
contain 2 div elements, so I would naturally expect those to be found.

Thanks Karl,
--rob

Reply via email to