Bug Tracker

Modify

Ticket #9594 (closed bug: duplicate)

Opened 2 years ago

Last modified 16 months ago

attr selectors in find, find nothing

Reported by: funkjunky8 Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.6.1
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 2 years ago by timmywil

  • Priority changed from undecided to high
  • Resolution set to duplicate
  • Status changed from new to closed
  • Component changed from unfiled to selector

comment:2 Changed 2 years ago by timmywil

Duplicate of #9261.

comment:3 Changed 2 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 2 years ago by dmethvin

  • Priority changed from high to 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.

comment:5 Changed 2 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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.