Bug Tracker

Opened 5 years ago

Closed 5 years ago

#10862 closed bug (invalid)

Sytax bug

Reported by: lakhtionov@… 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

Change History (1)

comment:1 Changed 5 years ago by ajpiano

  • Resolution set to invalid
  • Status changed from new to closed

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 (http://api.jquery.com/category/selectors/):

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="foo.bar", 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: http://jsfiddle.net/xvk3Z/

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

Note: See TracTickets for help on using tickets.