js实现两种99乘法表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>99乘法表</title> </head> <body> <script type="text/javascript"> var i=1; while(i <= 9){ var j=1;//每次都需重置j的值 while(j <= i){ document.write(j+"*"+i+"="+(i*j)+" "); j++; } i++; document.write("<br>") } </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>99乘法表</title> </head> <body> <script type="text/javascript"> for(var i=1; i<=9; i++) { for(var j=1; j<=i;j++)//j<=i { document.write(i+"*"+j+"="+(i*j)+" "); } document.write("<br>"); } document.write("<br>"); </script> </body> </html>