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.
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:
it works fine.