使用级联运算符 (+) 将两个字符串相加
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 运算符</h1>
- <p>+ 运算符串联(相加)字符串。</p>
- <p id="demo"></p>
- <script>
- var txt1 = "Bill";
- var txt2 = "Gates";
- document.getElementById("demo").innerHTML = txt1 + " " + txt2;
- </script>
- </body>
- </html>