-6
可能重複:
Double quote in JavaScript string逃逸單引號和雙引號中的JavaScript
var array=["famous quote by Shakespear is",""to be or not to be""]
如何逃脫在使用"
用於限制數組的第二個元素BLOCKQUOTE元素?
可能重複:
Double quote in JavaScript string逃逸單引號和雙引號中的JavaScript
var array=["famous quote by Shakespear is",""to be or not to be""]
如何逃脫在使用"
用於限制數組的第二個元素BLOCKQUOTE元素?
你可以用一個反斜槓逃逸,或使用字符串周圍單引號:
var array=["famous quote by Shakespear is","\"to be or not to be\""];
var array=["famous quote by Shakespear is",'"to be or not to be"'];
只要您正確配對,單引號和雙引號就可以互換。
使用反斜線:
var str = "famous quote by Shakespear is, \"to be or not to be\"";
var str = 'famous quote by Shakespear is, \'to be or not to be\'';
或者只混合型報價:
var str = "famous quote by Shakespear is, 'to be or not to be'";
var str = 'famous quote by Shakespear is, "to be or not to be"';
你真棒 – Gordon