对两个字符串相加,字符串之间有空格

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h1>JavaScript 运算符</h1>
  6.  
  7. <p>+ 运算符级联(相加)字符串。</p>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. var txt1 = "What a very";
  13. var txt2 = "nice day";
  14. document.getElementById("demo").innerHTML = txt1 + " " + txt2;
  15. </script>
  16.  
  17. </body>
  18. </html>