I have an html ID I'm trying to call. It has a specific name build like this name_|_anyting
but when I try to get the elemetn using Jquery's selectors I get an error
$("#name_|_anyting")
Error: Syntax error, unrecognized expression: |_anyting
so my question is : Are pipe characters not allowed as Ids in jquery selectors ?
Pipe character "|" has to be escaped using double backslashes.
http://api.jquery.com/category/selectors/
To update an old question... In jQuery 3.0 you can now use $.escapeSelector(selector). Examples:
and (from the docs)
|
is a special character in selector syntax, which means you can't use it directly in an ID selector. If you cannot change the ID in your markup to accommodate your selector, you'll have to make do with escaping the selector to trick jQuery into selecting the element anyway: