Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#9594 closed bug (duplicate)

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">&lt;= <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.

Change History (5)

comment:1 Changed 11 years ago by timmywil

Component: unfiledselector
Priority: undecidedhigh
Resolution: duplicate
Status: newclosed

comment:2 Changed 11 years ago by timmywil

Duplicate of #9261.

comment:3 Changed 11 years ago by funkjunky8

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.

comment:4 Changed 11 years ago by dmethvin

Priority: highlow

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.

comment:5 Changed 11 years ago by funkjunky8

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.

Note: See TracTickets for help on using tickets.