创建一个简单的乘法表 [英] Creating a simple multiplication table

查看:40
本文介绍了创建一个简单的乘法表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我编写的代码,包含在HTML文档中:

Here's the code i've written, which is included in a HTML document:

<script type="text/javascript">
var cipars = 10;
var i =0;
document.write('<table border="1" cellspacing="0" id="Tabula">');
for (i=1; i<10; i++) {
for (j=1; j<10; j++) {
document.write("<tr><td>" + i + " x " + j + " = " + j*i + "</td></tr>");    
}
}
document.write("</table>");
</script>

我的代码现在要做的是使乘法列比表更多.谁能给我一个提示,如何使它...更像一张桌子吗?我已经尽力解释了这个问题.

What my code does now is that makes a multiplication column more than a table. Can anyone give me a hint how to make it... More like a table? I've explained the problem as good as I can.

推荐答案

将其更改为此:

js

var cipars = 10;
var i =0;
document.write('<table border="1" cellspacing="0" id="Tabula">');
for (i=1; i<10; i++) {
    document.write("<tr>");
for (j=1; j<10; j++) {
    document.write("<td>" + i + " x " + j + " = " + j*i + "</td>");    
}
   document.write("</tr>");            
}
document.write("</table>");

这篇关于创建一个简单的乘法表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆