Skip to main content

Bug Tracker

Side navigation

#3329 closed bug (invalid)

Opened September 04, 2008 10:18PM UTC

Closed January 14, 2009 04:18AM UTC

Selectors don't work with jQuery context

Reported by: bartt Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: context Cc:
Blocked by: Blocking:
Description

Many (if not all) selectors don't work with jQuery context. See the demo on http://docs.jquery.com/Ajax/load#urldatacallback for example.

Other forms such as jQuery("#me", jQuery("<div id='notme'>notme</div> <div id='me'>ME!</div>") also fail. Same for jQuery("<div id='notme'>notme</div> <div id='me'>ME!</div>").find("#me").

It seems to be caused by the lack of nodeType in jQuery objects. Selectors that take context arguments check the nodeType to make sure they received an Element or Document type.

Attachments (0)
Change History (2)

Changed January 11, 2009 04:47AM UTC by dmethvin comment:1

jQuery(selector, context) is equivalent to jQuery(context).find(selector). The find method searches for matches BELOW the selected nodes. It is not the same as the filter method.

So, if you write your example this way:

jQuery("#me", jQuery("<div><div id='notme'>notme</div><div id='me'>ME!</div></div> "))

it works fine.

Changed January 14, 2009 04:18AM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed