JQuery: escaping plus sign in selector
For the dom element:
<li id="foo+bar"></li>
I want to refer to this element (using jQuery, if possible), and I'm trying:
$("#foo+bar")
and I also tried to avoid it too:
$("#foo\+bar")
.. but none of them work, because (I guess) jQuery cannot handle the plus sign that seems. Unfortunately, I have no way to change the id value, therefore:
Is there a way to get jQuery to get the correct dom, or how can I approach this problem?
+3
3 answers
Well, the problem is probably what +should not be.
The HTML 4 specification says:
ID NAME ([A-Za-z]), , ([0-9]), ( "-" ), ( "_" ), ( ":" ) ( "." ).
, - , . .
+6