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 Swedberg
www.englishrules.com
www.learningjquery.com

Reply via email to