Bug Tracker

Opened 14 years ago

Closed 14 years ago

#3329 closed bug (invalid)

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:


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.

Change History (2)

comment:1 Changed 14 years ago by dmethvin

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.

comment:2 Changed 14 years ago by dmethvin

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.