Skip to main content

Bug Tracker

Side navigation

#8861 closed bug (worksforme)

Opened April 13, 2011 02:38PM UTC

Closed April 16, 2011 05:42PM UTC

Selectors not evaluating integer variables correctly

Reported by: Tom English <> Owned by: Tom English <>
Priority: undecided Milestone:
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.


Attachments (0)
Change History (2)

Changed April 13, 2011 02:44PM UTC by timmywil comment:1

component: unfiledselector
owner: → Tom English <>
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on that reproduces the issue experienced to help us assess your ticket.

Additionally, test against the jQuery (edge) version to ensure the issue still exists.

Changed April 16, 2011 05:42PM UTC by addyosmani comment:2

resolution: → worksforme
status: pendingclosed

I've reproduced your test case here: 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: Both of these work fine in Firefox and Webkit based browsers without any issue. This also works fine in IE6. Closing ticket.