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>for循环乘法口诀表</title> 7 </head> 8 <body> 9 10 </body> 11 </html> 12 <style> 13 span { 14 display: inline-block; 15 width: 70px; 16 height: 25px; 17 border: 1px solid #096; 18 } 19 </style> 20 <script> 21 for (var m = 1; m <= 9; m++) { //行 22 for (var n = 1; n <= m; n++) { //列 23 document.write("<span>"); 24 document.write(n + "x" + m + "=" + n * m); 25 document.write("</span>"); 26 } 27 document.write("<br>"); 28 } 29 </script>