继承我的代码:
<body >
<script type ="text/javascript">
document.write("Multiplication Table </br> </br>")
var num = parseInt(prompt(" Enter a number:"));
var a;
document.write("<table border = '1' cellpadding = '0' cellspacing = '0>' ")
for(a=1;a<=10;a++){
{
document.write("<tr><td>"+ num + "x" + a + "=" + a * num + "<tr><td>");
}
}
document.write("</table>");
</script>
</body>
这应该是样本输出:
答案 0 :(得分:0)
需要读取数字并循环投掷它们,同时更正了td
和tr
document.write("Multiplication Table </br> </br>")
var num1 = parseInt(prompt("Input 1:"));
var num2 = parseInt(prompt("Input 2:"));
var a;
for(num=num1;num<=num2;num++){
document.write("<table border = '0' cellpadding = '0' cellspacing = '0' style='display:inline; margin:5px' >")
for(a=1;a<=10;a++){
{
document.write("<tr><td style='border:solid black 1px;'>"+ num + "x" + a + "=" + a * num + "</td></tr>");
}
}
document.write("</table>");
}