javascript实现九九乘法表

时间:2021-04-11 05:34:44

CSS代码部分:

 <style type="text/css">
table {
width: 800px;
height: 300px;
border-collapse: collapse;
}
td{border:1px solid red;}
</style>

JS代码部分:

 <script tjpe="teit/javascript">
document.write("<table>");
var str = "js九九乘法表";
document.write("<h1>" + str + "</h1>");
for ( var i = 1; i <= 9; i++) {
document.write("<tr>");
for ( var j = 1; j <= i; j++) {
document.write("<td>" + i + "*" + j + "=" + (i * j) + "</td>");
}
document.write("</tr>");
}
document.write("</table>");
</script>