javascript实现九九乘法表

CSS代码部分:

1 <style type="text/css">
2     table {
3     width: 800px;
4     height: 300px;
5     border-collapse: collapse;
6 }
7 td{border:1px solid red;}
8     </style>

JS代码部分:

 

 1 <script tjpe="teit/javascript">
 2     document.write("<table>");
 3     var str = "js九九乘法表";
 4     document.write("<h1>" + str + "</h1>");
 5     for ( var i = 1; i <= 9; i++) {
 6         document.write("<tr>");
 7         for ( var j = 1; j <= i; j++) {
 8             document.write("<td>" + i + "*" + j + "=" + (i * j) + "</td>");
 9         }
10         document.write("</tr>");
11     }
12     document.write("</table>");
13    </script>

 

posted @ 2016-10-11 19:32  smille2020  阅读(8692)  评论(0编辑  收藏  举报