5_字符串基本操作.html 840 B

123456789101112131415161718192021222324252627282930313233343536
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <style>
  8. .box{
  9. color: red;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14. <script>
  15. // + 左右两边有字符串出现则 变成字符串拼接
  16. var userName = "张三";
  17. console.log("恭喜"+userName+"中奖了");
  18. var a = 10;
  19. var b = "20";
  20. console.log(a+b);
  21. // document.write("恭喜"+userName+"中奖了");
  22. // 如果用引号表示一段字符串 那么外面用双引号里面用单引号 外面用单引号里面用双引号
  23. // document.write("<h1 class='box'>hello world</h1>");
  24. document.write('<h1 class="box">hello world</h1>');
  25. </script>
  26. </body>
  27. </html>