用for循环实现九九乘法表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/f120032777/article/details/72921064
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">

     table{width: 1000px;height: 500px;}

     table td{ text-align: center; border: 1px solid #000; border-collapse: collapse ;}


</style>
</head>
<body>
<script type="text/javascript">
     document.write("<table cellpadding='0' cellspacing='0'>")                   //打印表格 
     for(var i=1;i<10;i++){                //定义变量i,i<10,即i的取值范围石1~9
     document.write("<tr>")               //打印行
     for(var j=1;j<=i;j++){               //定义变量j,j<10,即j的取值范围石1~9


     document.write("<td>"+i+"*"+j+"="+i*j+"</td>")               //打印列


     }
     document.write("</tr>")

     }
     document.write("</table>")
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/f120032777/article/details/72921064