Side navigation
#5870 closed bug (invalid)
Opened January 19, 2010 07:50PM UTC
Closed October 08, 2010 01:33AM UTC
Specifying context fails for selector when context is a wrapped string
Reported by: | tvanfosson | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | core | Version: | 1.4 |
Keywords: | context selector | Cc: | |
Blocked by: | Blocking: |
Description
When checking a string for the existence of an element by specifying the string as a wrapped jQuery as the context, the selector fails.
var html = '<div>test</div>';
var exists = $('div', $(html)).length > 0;
This code results in exists === false, when clearly the the string contains a valid divelement.
Yet, if the element is added to the document (when it previously contained no divs), it does properly find the element
$('body').append(html);
var exists2 = $('div').length > 0;
Attachments (1)
Change History (2)
Changed January 20, 2010 02:21AM UTC by comment:1
Changed October 08, 2010 01:33AM UTC by comment:2
resolution: | → invalid |
---|---|
status: | new → closed |
Invalid: I believe the explanation offered by dmethvin satisfactorily explains why this particular bug isn't actually a valid jQuery core issue.
Further information regarding your original concerns can be addressed by looking at the API documentation site as previously suggested.
Closing as there has been no further activity on this ticket for a long time and it appears to have been resolved.
So,
is the same as .The
method looks *below* the nodes provided. There are no elements *contained* in the context. See the documentation for jQuery(), .find(), and .filter():http://api.jquery.com/jQuery/