js实现两种99乘法表

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>99乘法表</title>
</head>
<body>
<script type="text/javascript">
    var i=1;
    while(i <= 9){
        var j=1;//每次都需重置j的值
        while(j <= i){
            document.write(j+"*"+i+"="+(i*j)+"&nbsp;");
            j++;
        }
        i++;
        document.write("<br>")
    }
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>99乘法表</title>
</head>
<body>
<script type="text/javascript">
    for(var i=1; i<=9; i++)
    {
        for(var j=1; j<=i;j++)//j<=i
        {
            document.write(i+"*"+j+"="+(i*j)+"&nbsp;");
        }
        document.write("<br>");
    }
    document.write("<br>");
   
</script>
</body>
</html>

 

posted @ 2017-02-10 10:27  雨落知音  阅读(215)  评论(0编辑  收藏  举报