05循环结构

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 6     <title>Document</title>
 7 
 8     <script>
 9         /*
10             往浏览器窗口上打印
11         */
12         document.write("<h1>中国矿业大学<h1>")
13         document.write("<hr>")
14         
15         /*
16             while for foreach
17         */
18         var arr = ["北京","上海","广州"]
19         document.write("<ul>")
20         /* 直接打印 index ,是数组中元素对应索引*/
21         for(var index in arr){
22             document.write("<li>"+arr[index]+"</li>")
23         }
24         document.write("</ul>")
25 
26     </script>
27 
28 </head>
29 <body>
30     
31 </body>
32 </html>

 

posted @ 2024-03-14 22:30  白茶花约  阅读(14)  评论(0)    收藏  举报