使用JavaScript脚本在页面上显示输出

 1 <!DOCTYPE html>
 2 <html>
 3 
 4 <head>
 5     <meta charset="UTF-8">
 6     <title>使用JS脚本在页面上显示输出</title>
 7 </head>
 8 
 9 <body>
10 
11 <script type="text/javascript">
12     document.write("<h1>This is a heading.</h1>");
13     for (var i = 0; i < 5; i++) {
14         if (i > 0) {
15             document.write("<p>This is a par.</p>");
16         } else {
17             document.write("<p><strong>This is a par.</strong></p>");
18         }
19     }
20 </script>
21 
22 </body>
23 
24 </html>