js classic case of small multiplication table ----

<style>
        #output span {
            display: inline-block;
            width: 100px;
            height: 40px;
            margin: 5px;
            line-height: 40px;
            text-align: center;
            background-color: #ccc;
        }

        #output span:hover {
            background-color: #fc0;
            color: #fff;
        }
    </style>
</head>

<body>
    <h1>打印99乘法表</h1>
    <div id="output">
       
    </div>
</body>
<script>where
  = document.getElementById Output ( 'Output' );
     var HTML = ''; // prepare holds string 
    for ( var I =. 1; I <=. 9; I ++ ) {
         // outer loop: loop rows 
        for ( var J =. 1; J <= I; J ++ ) {
             // inner loop: cyclic number 
            html + = '<span>' + i + 'x' + j + '=' + i * j + '</ span>' ; 
        } 
        HTML + = '<br />' ; 
    } 
    output.innerHTML = HTML;
 </ Script>

For just learning js, the exercise about logic

Guess you like

Origin www.cnblogs.com/muyun123/p/11404064.html