[Js Master Road Part 1] Hundreds of JavaScript examples [new version] _8 javascript double loop, break and continue statement

 

Output a table with 5 rows and 5 columns

 

Implemented using a double loop

 

 

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <style>
 7         table {
 8             /*合并单元格之间的线*/
 9             border-collapse: collapse;
10         }
11         th,td {
12             border: 1px solid #ccc;
13             padding: 5px;
14             width: 50px;
15             height: 50px;
16         }
17     </style>
18     <script>
19         //输出5行5列的表格
20         document.write("<table>");
21         for (var i=0;i<5;i++) {
22             document.write("<tr>");
23             for (var j=0;j<5;j++) {
24                 document.write("<td> </td>");
25             }
26             document.write("</tr>");
27         }
28         document.write("</table>");
29     </script>
30 </head>
31 <body>
32 
33 </body>
34 </html>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325394336&siteId=291194637