実際には、単一の引用と二重引用符の間に違いはありません。それはあなたがそれに慣れることに依存します。
コードコピーは次のとおりです。
<input type="button" onclick="alert("1")">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<input type="button" onclick="alert('1')">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
このような二重引用符で二重引用符を使用してください。
var str = "abc/" def/"ghi"
バックスラッシュを使用して、二重引用符を無効にします。
ここに私からの抜粋があります、私はそれがあなたに役立つことを願っています:
Webページのボタンに、誤って次のように書かれたOnClickイベント処理コードを書きます。
コードコピーは次のとおりです。
<入力値= "test" type = "button" onclick = "alert(" "ok" ");" />
IEプロンプトエラーが発生した後、何気なく変更されます。
コードコピーは次のとおりです。
<入力値= "test" type = "button" onclick = "alert(/" ok/");" />
結果はまだエラーです。
この時点で、私はそれを理解することができませんでしたが、私は最も直接的な解決策はそれをこのように書くことだと知っていました:
コードコピーは次のとおりです。
<入力値= "" type = "ボタン" onclick = "alert( 'ok');" />
しかし、なぜJavaScriptでエスケープキャラクター/無料なのでしょうか?
後で私は通常のコードを見つけました:
コードコピーは次のとおりです。
<入力値= "test" type = "button" onclick = "alert(" ok ");" />
そうして初めて、現時点ではまだHTMLの管轄内にあることを理解したため、JavaScriptではなくHTMLでエスケープキャラクターを使用する必要があります。 2つの二重引用符はvbscript、 /「この方法はjavascript、htmlであり、使用されます」、「」、「、」も使用できます。
以下はさまざまな表現方法です。
コードコピーは次のとおりです。
<html>
<body>
<input値= "double quotes-error" type = "button" onclick = "alert(" ok ");" onclock-error内の外側のquotes /> <br />
<入力値= "単一quotes-error内の外部quotes" type = "button" onclick = 'alert(' ok ');' /> <br />
<入力値= "2つのdouble quotes-error" type = "button" onclick = "alert(" "ok" ");" /> <br />
<入力値= "2つの単一quotes-error" type = "button" onclick = "alert( '' ok '');" /> <br />
<入力値= "/+double quotes -error" type = "button" onclick = "alert(/" ok/");" /> <br />
<入力値= "/+single quotes-error" type = "button" onclick = "alert(/'ok/');" /> <br />
<input値= "単一quotes-ok" type = "button" onclick = "alert( 'ok');" onclick "type =" button内の外側のquotes /> <br />
<入力値= "外部引用と二重引用符-OK" type = "ボタン" onclick = 'alert( "ok");' /> <br />
<input値= "outside -ok" type = "button" onclick = alert( 'ok'); alert( "ok"); /> <br />
<入力値= "HTMLエスケープ文字"(&#3 4;) - ok "type =" button "onclick =" alert( "ok"); " /> <br />
<入力値= "htmlエスケープ文字 '(&#3 9;) - ok" type = "button" onclick = "alert(' ok ');" /> <br />
<入力値= "htmlエスケープ文字"(&#x 2 2;) - ok "type =" button "onclick =" alert( 'ok'); " /> <br />
<入力値= "htmlエスケープ文字 '(&#x 2 7;) - ok" type = "button" onclick = "alert(' ok ');" /> <br />
<入力値= "HTMLエスケープ文字"(&quot;) - ok "type =" button "onclick =" alert( "ok"); " /> <br />
<入力値= "htmlエスケープ文字"(&apos;) - ie error "type =" button "onclick =" alert( 'ok'); " /> <br />
<入力値= "その他// - エラー" type = "button" onclick = "alert(//" ok // ");" /> <br />
<入力値= "other/&#3 4; -Error" type = "button" onclick = "alert(/" ok/");" /> <br />
</body>
</html>