tags:

views:

71

answers:

3

I want to use this following in jQuery

:contains("C:\ My Name")

How do I escape the escape character?

+3  A: 

Use a double backslash. Also, you probably want to remove the leading space from " My Name" as that is not a valid path.

:contains("C:\\My Name")
Daniel Dyson
+5  A: 

Use a double \\ to get a single, like this:

:contains("C:\\ My Name")

You can test it here. You can find other tips like this at the top of the selectors portion of the API.

Nick Craver
Thanks Nick. One more thing, what about the spaces. It doesn't work without escape characters.
Rajasankar
@Rajasankar - Are you using quotes? for example: `$('span:contains("C:\\ My Name")')`
Nick Craver
A: 

Use a back-slash to escape itself. \\

:contains("C:\\My Name")

Ruel
This is not a forward slash.
elusive
Yep, my bad. edited.
Ruel