1. 程式人生 > >九九乘法表js

九九乘法表js

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<!--順的九九乘法表-->
		<script type="text/javascript">
			document.write('<table border="1" cellpadding="0" cellspacing="0" bgcolor="greenyellow" width="960px">');
				for(var i=1;i<=9;++i){
					document.write('<tr>');
						for(var j=1;j<=i;j++){
							document.write('<td>'+i+'X'+j+'='+(i*j)+'</td>')
						}
					document.write('</tr>');
				}
			document.write('</table>');
		</script>
		
		<!--倒的九九乘法表-->
		<script type="text/javascript">
			document.write('<th color="red">')
			document.write('<table border="1" cellpadding="0" cellspacing="0" bgcolor="blue" width="960px">');
				for(var i=9;i>=1;i--){
					document.write('<tr>');
						for(var j=1;j<=i;j++){
							document.write('<td>'+i+'X'+j+'='+(i*j)+'</td>')
						}
					document.write('</tr>');
				}
			document.write('</table>');
		</script>
	</body>
</html>