Html+Css+Js(for 结构语句)1-100 之间所有数、打印 9*9 乘法表。
作者:互联网
Html部分
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script src="js/index.js" type="text/javascript" charset="utf-8"></script>
</head>
<body οnlοad="panduan()">
<div id="box1"></div>
<div id="box2">打印 9*9 乘法表<br></div>
</body>
</html>
Css部分
* {
margin: 0;
padding: 0;
}
#box1{
width: 30%;
margin: 100px auto;
text-align: center;
}
#box2{
width: 98%;
margin: 100px auto;
text-align: center;
}
Js部分
function panduan() {
var box1 = document.getElementById('box1');
var box2 = document.getElementById('box2');
var result1 = "";
var result2 = 0;
// 1-100 之间所有数
for (var i = 1; i < 100; i++) {
result1 = result1 + i + '、';
}
result1 = result1 + 100;
// 打印 9*9 乘法表
for (var j = 1; j <= 9; j++) {
for (var k = 1; k <= j; k++) {
result2 = result2+j + ' * ' + k + ' = ' + j * k;
}
box2.innerHTML =box2.innerHTML+result2+'<br/>';
}
box1.innerHTML = '1-100 之间所有数:' + result1;
}
标签:box1,result2,result1,Html,var,100,Js,乘法表,box2 来源: https://blog.csdn.net/gly_technology/article/details/122604463