Bug Tracker

Opened 12 years ago

Closed 12 years ago

#8861 closed bug (worksforme)

Selectors not evaluating integer variables correctly

Reported by: Tom English <[email protected]…> Owned by: Tom English <[email protected]…>
Priority: undecided Milestone: 1.next
Component: selector Version: 1.5.1
Keywords: Cc:
Blocked by: Blocking:


When using the jquery selector like so:

$('input[name="product[id]"][value="' + product_id + '"]')

Where the variable product_id is equal to an integer, jquery returns incorrect matches. If product_id is in the range 10-19 then it will match to inputs with the value of 1, if it is 20-29 it will match 2 and so on.

To get jQuery to select the correct objects I did the following:

var selector = 'input[name="product[id]"][value="' + product_id + '"]';

I think that the problem lies in the order/way that jquery is evaluating the arguments of the selector.


Change History (2)

comment:1 Changed 12 years ago by timmywil

Component: unfiledselector
Owner: set to Tom English <[email protected]…>
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsFiddle.net that reproduces the issue experienced to help us assess your ticket. Additionally, test against the jQuery (edge) version to ensure the issue still exists.

comment:2 Changed 12 years ago by addyosmani

Resolution: worksforme
Status: pendingclosed

I've reproduced your test case here: http://jsfiddle.net/addyosmani/mFYSP/ and just in case you're not actually passing the id directly to your first selector and mean 'id' literally, I've also tested here: http://jsfiddle.net/PbfG9/1/. Both of these work fine in Firefox and Webkit based browsers without any issue. This also works fine in IE6. Closing ticket.

Note: See TracTickets for help on using tickets.