2014-01-27 29 views
-1

我有一個愚蠢的問題,但對我很重要。如何重寫'在document.write在JavaScript?例如:javascript override'in document.write

 document.write('Sent's Lois'); 

你看到的問題是一部分發送的-'s-因爲javasript considere,作爲最終Lois的...... 這對我來說是一個問題,我是想:

 document.write('Lois'); 
     document.write('s Lois'); 

但這不是因爲你得到document.write('Sent s Lois');並且你錯過了發送的再次.....任何幫助,請...... ......

+0

「除了常規的,可打印字符,特殊字符可以使用轉義符號進行編碼。「從[MDN String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) – Givi

回答

1

您正在尋找的術語是轉義報價。使用反斜槓這樣做:

document.write('Sent\'s Lois'); 
2

您可以嘗試

document.write("Sent's Lois"); 
+1

您也可以嘗試'document.write('Sent \'Lois') ;' –

+0

是的,我們可以,但是當我們必須在單個字符串中轉義多個引號時,這會變得非常混亂。有 –

+0

有案件和案件。 –