Skip to main content

Bug Tracker

Side navigation

#10862 closed bug (invalid)

Opened November 22, 2011 06:39PM UTC

Closed November 22, 2011 06:52PM UTC

Sytax bug

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

jQuery has a problem dealing with the "+" character.


<input id="hello+2" value="wagon" />

alert($('#hello+2').val()); displays: undefined

alert(document.getElementById('hello+2').value); displays: wagon

Attachments (0)
Change History (1)

Changed November 22, 2011 06:52PM UTC by ajpiano comment:1

resolution: → invalid
status: newclosed

Thanks for taking a moment to try to help the jQuery project, but this is not a valid bug. + is a selector (for adjacent siblings). As is stated in the selectors docs (

If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\\]^`{|}~ ) as a literal part of a name, you must escape the character with two backslashes: \\\\. For example, if you have an element with id="", you can use the selector $("#foo\\\\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors.

It works fine once you do the escaping:

In the future please provide a test case and search the documentation before filing a bug.