用js做一个九九乘法表(表格)

516 阅读1分钟
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.box{
				border: 1px solid #000;
				border-collapse: collapse;
				color: red;
			}
			.box_td{
				width: 80px;
				text-align: center;
				background-color: yellow;
				height: 30px;
				line-height: 30px;
			}
		</style>
	</head>
	<body>
		<script type="text/javascript">
			document.write("<table class='box' cellpadding='0' cellspacing='15' align='center' border='1'>");
			for (var i = 9; i >=0; i--) {
				document.write("<tr class='box_tr'>")
				for (var j = 1; j <= i; j++) {
						document.write("<td class='box_td'>" + j + "&times;" + i + "=" + i * j +"</td>");
				}
				document.write("</tr>")
			}
			document.write("</table>");
		</script>
	</body>
</html>