Return to Snippet

Revision: 40415
at February 1, 2011 19:57 by bitstream


Initial Code
function jqescape(str) {
    return str.replace(/[#;&,\.\+\*~':"!\^\$\[\]\(\)=>|\/\\]/g, '\\$&');
}

Initial URL


Initial Description
f 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 an element with id="foo.bar", you can use the selector $("#foo\\.bar").

Initial Title
jquery escape meta chars

Initial Tags
jquery

Initial Language
JavaScript