HTML/javascript打印九九乘法表

时间:2024-03-24 07:58:52
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>九九乘法表</title>
    <style>
        *{padding: 0;
        margin: 0}
        table {
            border: 2px solid black;
            text-align: center;
            width: 800px;
            height: 400px;
            margin-top: -150px;
            border-collapse: collapse;
            }
        td {
            border: 1px solid black;
                   }
    </style>
</head>
<body>

<script type="text/javascript">
    <!--col代表列-->
    /*row代表行*/
document.write('<table>');
    for (var row=1;row<=9;row++){
        document.write('<tr>');
        for (var col=1;col<=row;col++){
            var ji=col*row;
            document.write('<td>'+col+'*'+row+'='+ji+'&nbsp'+'<td>' );
        }
        document.write('</tr>');
        document.write('<br>')
    }
document.write('</table>');
</script>
</body>
</html>

HTML/javascript打印九九乘法表