<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
//形式一
document.write("<table>");for (var i = 1; i < 10; i++) {
document.write("<tr>");
for (var j = 1; j<= i; j++) {
document.write("<td>"+j+"*"+i+"="+i*j+"</td >");
}
document.write("</tr>");
}
document.write("</table>");
document.write("------------------------------------------------------------");
//形式二
document.write("<table>");
for (var i = 9; i >0; i--) {
document.write("<tr>");
for (var j = 1; j<= i; j++) {
document.write("<td>"+j+"*"+i+"="+i*j+"</td >");
}
document.write("</tr>");
}
document.write("</table>");
document.write("------------------------------------------------------------");
//形式三
document.write("<table>");
for (var i = 1; i < 10; i++) {
document.write("<tr>");
for (var a = 1; a<10-i; a++) {
document.write("<td> </td >");
}
for (var j = i; j>0; j--) {
document.write("<td>"+i+"*"+j+"="+i*j+"</td >");
}
document.write("</tr>");
}
document.write("</table>");
document.write("------------------------------------------------------------");
//形式四
document.write("<table>");
for (var i = 9; i >0; i--) {
document.write("<tr>");
for (var a = 1; a<10-i; a++) {
document.write("<td> </td >");
}
for (var j = i; j>0; j--) {
document.write("<td>"+i+"*"+j+"="+i*j+"</td >");
}
document.write("</tr>");
}
document.write("</table>");
</script>
</head>
<body>
</body>
</html>
效果一:
效果二
效果三
效果四: