Side navigation
#9594 closed bug (duplicate)
Opened June 15, 2011 05:49PM UTC
Closed June 15, 2011 07:11PM UTC
Last modified March 09, 2012 05:49AM UTC
attr selectors in find, find nothing
Reported by: | funkjunky8 | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | selector | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery 1.6
Chrome 11
Mac OS X Snow Leopard
JSFiddle: http://jsfiddle.net/ScN4a/
alert(newKeyValueRow.find('input[name*="from"]').length);
alert(newKeyValueRow.find('input[name~="from"]').length);
alert(newKeyValueRow.find('input[name|="bucket_from"]').length);
alert(newKeyValueRow.find('input[name]').eq(1).attr("name"))
These output:
1
0
0
bucket_from[0][]
The html is as follows (taken from the developer tools of chrome):
<tr class="bucketRow"> <td> <input type="text" name="bucket_to[0]" value=""></td> <td class="bucketValueTD"><= <input type="text" name="bucket_from[0][]" value=""> <input type="button" class="bucket_add_row" value="add value"> </td> </tr>
JSFiddle: http://jsfiddle.net/ScN4a/
(note: I put the alerts into a click of the button.)
As far as I understand, the first two alerts ABSOLUTELY should show the same thing.
The third one should as well, but it is a little less obvious, although still fairly obvious.
Attachments (0)
Change History (5)
Changed June 15, 2011 07:11PM UTC by comment:1
component: | unfiled → selector |
---|---|
priority: | undecided → high |
resolution: | → duplicate |
status: | new → closed |
Changed June 15, 2011 07:30PM UTC by comment:3
If you insist.
The bug referenced appears to refer to the attribute existing, while my bug expands the issue to matching attributes using specific selectors.
Changed June 15, 2011 07:49PM UTC by comment:4
priority: | high → low |
---|
You're right, it's not a dup, I think it's invalid.
~=
is the "contains word" selector; input[name~="from"]
shouldn't match anything because there is no *space-delimited* string from
in the markup. http://api.jquery.com/attribute-contains-word-selector/
|=
is the "contains prefix" selector; input[name|="bucket_from"]
shouldn't match anything because there is no name that is either exclusively that string or prefix that string *followed by a dash*. http://api.jquery.com/attribute-contains-prefix-selector/
It's best to start on the forum with questions like this and only file a bug once you've got some consensus that it's really a bug.
Changed June 15, 2011 07:54PM UTC by comment:5
I see now.
I misunderstood the use of those 2 functions.
Next time I will query the forum before submitting a bug.
Sorry about the false report, and thanks for the reply.