js 利用for循环实现九九乘法表

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            border-collapse: collapse;
            width: 800px;
        }
        td{
            border: 1px solid forestgreen;
            height: 30px;
            line-height: 30px;
            text-align: center;
        }
    </style>
</head>
<body>
    <script>
        var table="<table>";
        for(var i=1;i<=9;i++){
            table+="<tr>"
            for(var j=1;j<=i;j++){
                table+="<td>"+i+"*"+j+"="+i*j+"</td>";
            }
            table+="</tr>"
        }
        table+="</table>";
        document.write(table);
    </script>
</body>
</html>

版权声明:本文为u012120710原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。