Reputation: 2973
How to concat character \
as a string to a text in javascript?
I want to write this code line in javascript:
var x = "$$\" + $("#formul").val() + "$$";
How to do this?
Upvotes: 1
Views: 5340
Reputation: 166021
Escape the backslash:
var x = "$$\\" + $("#formul").val() + "$$";
The problem you have currently is that the backslash is the escape character. It escapes the following "
character so your string doesn't close.
Upvotes: 5