2009-08-04 126 views
1

Javascript變量報價

我想在一個雙引號給一個JavaScript變量,任何一個可以幫助我嗎?

+4

你能詳細說明一下嗎?或許提供你* *認爲這將是一個代碼示例,我們可以糾正? – seanmonstar 2009-08-04 07:22:24

回答

3

您是否嘗試過在雙引號前面使用\逃脫字符?

var myVar="this is my text in \"double quotes\""; 
3

使用json_encode()

var myString = <?=json_encode('This is a "test".');?>; 
+1

我沒有看到,PHP是關於這個問題的標籤 – 2009-08-04 08:03:52

1

認爲你所談論的字符串連接。如果是這樣,它就像:

a = "word"; 
b = "there should be another " + a + " in the middle of this string.";