Bug Tracker

Modify

Ticket #10862 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

Sytax bug

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

Description

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

ex.

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

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

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

Change History

comment:1 Changed 2 years ago by ajpiano

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

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.

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.