Cannot nest single quotes in single quotation marks
Double quotation marks cannot be nested in double quotes
<input type= "button" onclick= "Alert (" 1 ")" >-------------------Incorrect
<input type= "button" onclick= "alert (' 1 ')" >-------------------correct
Double quotation marks in double quotes to do this:
var str = "abc\" def\ "Ghi"
Suppresses the parsing of double quotes with backslashes.
<body>
<input value= "Outside double quotation marks-error" type= "button" onclick= "alert (" OK ");"/><br/>
<input value= "Outer single quotation mark-error" type= "button" onclick= ' Alert (' OK '); '/><br/>
<input value= "Two double quotes-error" type= "button" onclick= "alert (" OK ""); "/><br/>
<input value= "Two single quotes-error" type= "button" onclick= "Alert (" OK ");"/><br/>
<input value= "\+ double quotes-Error" type= "button" onclick= "alert (\" Ok\ ");"/><br/>
<input value= "\+ single quote-Error" type= "button" onclick= "alert (\ ' Ok\ ');"/><br/>
<input value= "outer double quotation mark inside single quotation mark-ok" type= "button" onclick= "alert (' OK ');"/><br/>
<input value= "Outer single quotation mark inside double quotes-ok" type= "button" onclick= ' Alert ("OK"); '/><br/>
<input value= "External does not use quotation marks-ok" type= "button" Onclick=alert (' OK '); Alert ("OK"); /><br/>
<input value= "HTML escape Character" (& # 3 4;)-ok "type=" button "onclick=" alert ("OK"); "/><br/>
<input value= "HTML escape Character" (& # 3 9;)-ok "type=" button "onclick=" alert (' OK '); "/><br/>
<input value= "HTML escape Character" (& # x 2 2;)-ok "type=" button "onclick=" alert (' OK '); "/><br/>
<input value= "HTML escape Character" (& # x 2 7;)-ok "type=" button "onclick=" alert (' OK '); "/><br/>
<input value= "HTML escape character" (& q u o t;)-ok "type=" button "onclick=" alert ("OK"); "/><br/>
<input value= "HTML escape Character" (& A P o s;)-ie error "type=" button "onclick=" alert (' OK '); "/><br/>
<input value= "Other \\-Error" type= "button" onclick= "alert (\ \" ok\\ ");"/><br/>
<input value= "Other \& # 3 4;-Error" type= "button" onclick= "alert (\" Ok\ ");"/><br/>
</body>
Http://www.jb51.net/article/42825.htm
Simple analysis of single quotation mark and double quotation mark problem in JS