使用 += 运算符对两个字符串相加

  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. txt1 = "Hello ";
  13. txt1 += "Kitty!";
  14. document.getElementById("demo").innerHTML = txt1;
  15. </script>
  16.  
  17. </body>
  18. </html>