1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>99乘法表</title> 6 </head> 7 <body> 8 <script type="text/javascript"> 9 var i=1; 10 while(i <= 9){ 11 var j=1;//每次都需重置j的值 12 while(j <= i){ 13 document.write(j+"*"+i+"="+(i*j)+" "); 14 j++; 15 } 16 i++; 17 document.write("<br>") 18 } 19 </script> 20 </body> 21 </html>
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>99乘法表</title> 6 </head> 7 <body> 8 <script type="text/javascript"> 9 for(var i=1; i<=9; i++) 10 { 11 for(var j=1; j<=i;j++)//j<=i 12 { 13 document.write(i+"*"+j+"="+(i*j)+" "); 14 } 15 document.write("<br>"); 16 } 17 document.write("<br>"); 18 19 </script> 20 </body> 21 </html>