1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>99乘法表</title> <style> #box span{ display: inline-block; line-height: 40px; text-align: center; height:40px; width:100px; border: 1px solid black ; } </style> </head> <body> <dvi id="box"></dvi> <script> let num = 9; let str= "" ; let box = document.getElementById("box"); for(var i = 0 ; i < num; i++) { for(var j = 0 ; j <= i ; j++) { str += `<span>${(j+1)}x${(i+1)}=${(i+1)*(j+1)}</span>`; } str += "<br>"; } box.innerHTML = str; </script> </body> </html>
|