public static String escapeJQuerySpecialCharsInSelector ( String selector ) { String jQuerySpecialChars = "!\"#$%&'()*+,./:;<=>?@[]^`{|}~;" ; String [ ] jsc = jQuerySpecialChars . split ( "(?!^)" ) ; for ( String c : jsc ) { selector = selector . replace ( c , "\\\\" + c ) ; } return selector ; }
Escape special jQuery chars in selector query