From 384a5a39d20830dfa0e66120e9f4a0c6aed782ca Mon Sep 17 00:00:00 2001 From: Chris Payne Date: Tue, 5 Apr 2016 11:38:20 +0100 Subject: [PATCH] Fix for replace string in example function I'm on latest Chrome, and the line `return "#" + myid.replace( /(:|\.|\[|\]|,)/g, "\\$1" )` results in only a single backslash being inserted before each match, as opposed to double backslash, eg `hello:world` > `hello\:world` Changing to `return "#" + myid.replace( /(:|\.|\[|\]|,)/g, "\\\\$1" )` fixes this. --- ...element-by-an-id-that-has-characters-used-in-css-notation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/page/using-jquery-core/faq/how-do-i-select-an-element-by-an-id-that-has-characters-used-in-css-notation.md b/page/using-jquery-core/faq/how-do-i-select-an-element-by-an-id-that-has-characters-used-in-css-notation.md index c29fcdd9..d21661a9 100644 --- a/page/using-jquery-core/faq/how-do-i-select-an-element-by-an-id-that-has-characters-used-in-css-notation.md +++ b/page/using-jquery-core/faq/how-do-i-select-an-element-by-an-id-that-has-characters-used-in-css-notation.md @@ -25,7 +25,7 @@ The following function takes care of escaping these characters and places a "#" ``` function jq( myid ) { - return "#" + myid.replace( /(:|\.|\[|\]|,)/g, "\\$1" ); + return "#" + myid.replace( /(:|\.|\[|\]|,)/g, "\\\\$1" ); } ```