JavaScript 语句可以在代码块中组合在一起
- <!DOCTYPE html>
- <html>
- <body>
- <h2>JavaScript 语句</h2>
- <p>JavaScript 代码块在 { 与 } 之间编写。</p>
- <button type="button" onclick="myFunction()">点击我!</button>
- <p id="demo1"></p>
- <p id="demo2"></p>
- <script>
- function myFunction() {
- document.getElementById("demo1").innerHTML = "Hello Kitty.";
- document.getElementById("demo2").innerHTML = "How are you?";
- }
- </script>
- </body>
- </html>