JS,There's no difference between single and double quotes, just look at your own habits.However, if you use double quotes in double quotation marks, you need to use backslashes to suppress the parsing of double quotes: alert("ABC\"def\ "ghi");
But the following situation needs to understand: In a page button, write the onclick event processing code, accidentally written as follows:
<inputtype="button"onclick="Alert("1 ")"/>-------------------incorrect IE prompt after the error, then casually changed to:
<inputtype="button"onclick="Alert(\"1\ ")"/>----------------not correct
The result is still wrong.at this time, I can not understand, although I know the most direct solution is written like this:
<inputtype="button"onclick="Alert(' 1 ')" />-------------------CorrectBut why is the escape character in JavaScript \ No effect?
This is because the code is still in the jurisdiction of the HTML, so the escape character should be HTML, not JavaScript.<inputvalue="double quotes"type="button"onclick="Alert(" double quotes the;);" /> -------------------correct
<inputvalue="single quote"type="button"onclick="Alert(' single quote the;);" />-------------------Correct
Summary
<inputValue="double quotes inside double quotes-Error"Type="button"onclick="Alert("OK ");"/>
<inputValue="Single quotation mark in outer single quote-error"Type="button"onclick='Alert('OK '); '/>
<inputValue="Two double quotes-error"Type="button"onclick="Alert(""OK" ");"/>
<inputValue="Two single quotes-error"Type="button"onclick="Alert("'Ok"');" />
<inputValue="Backslash \+ double quote-Error"Type="button"onclick="Alert(\"Ok\ ");"/>
<inputValue="Backslash \+ single quote-Error"Type="button"onclick="Alert(\' OK\ ');" />
<inputValue="outer double quotes single quote-ok"Type="button"onclick="Alert(' OK ');" />
<inputValue="Outer single quote double quotation mark-ok"Type="button"onclick='Alert("OK");'/>
<inputValue="External not using quotation marks-ok"Type="button"onclick=Alert(' OK '); />
Note: It is possible to transfer characters internally using HTML single or double quotes
From for notes (Wiz)
JS HTML single quote and double quotation mark