Unhandled exception: syntax error, unrecognized jQuery expression

I am having problems with jQuery 1.6, I'm trying to select this $('#' + id) object, where id looks like skill|3345015|7868 , but the console always gives me:

Error: uncaught exception: syntax error, unrecognized expression: | 3345015 | 7868

thanks for the help

+7
source share
2 answers

Try it -

 $("div[id='skill|3345015|7868']") 

You will need to replace the "div" with whatever element you are looking for. Or, to search for all the elements -

 $("*[id='skill|3345015|7868']") 

Demo - http://jsfiddle.net/dV7xM/

+14
source

According to w3.org

Signs

ID and NAME must begin with a letter ([A-Za-z]) and can be followed by any number of letters, numbers ([0-9]), hyphen ("-"), underscore ("_"), colon ( ":") and periods (".").

So basically you have an invalid id, and that should be the reason for the parsing error.

+8
source

All Articles