声明(创建)字符串
- <!DOCTYPE html>
- <html>
- <body>
- <h2>JavaScript 字符串</h2>
- <p>您可以在字符串内使用引号,只要这些引号与包围字符串的引号不匹配:</p>
- <p id="demo"></p>
- <script>
- var answer1 = "It's alright"; // 双引号内的单引号
- var answer2 = "He is called 'Bill'"; // 双引号内的单引号
- var answer3 = 'He is called "Bill"'; // 单引号内的双引号
- document.getElementById("demo").innerHTML =
- answer1 + "<br>" +
- answer2 + "<br>" +
- answer3;
- </script>
- </body>
- </html>