Need to send two kinds of quotes in a string via jQuery
I'm sending some html via jQuery, and in this html are various values that need to be quoted, and in one instance, there's a nested value, so I have to be able to send both kinds of quotes. Here's some mock code:
var myVar = "<tag value='foo' value2="config={'bar':null, 'foo2':true}" />";
How can in ensure 开发者_JS百科that the double quotes are sent properly?
You can escape them.
var myVar = "<tag value='foo' value2=\"config={'bar':null, 'foo2':true}\" />";
you can escape the double quotes inside the string, by adding a slash in front of it.
like this
"some text \" more text"
精彩评论