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="";for(var i=1;i<=9;i++){
            table+=""for(var j=1;j<=i;j++){
                table+="";}
            table+=""}
        table+="
"+i+"*"+j+"="+i*j+"
"
; document.write(table); </script> </body> </html>

你可能感兴趣的:(JavaScript,过程式编程)