<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>循环结构</title>
<script>
//金字塔乘法表
for(var n =1; n <10; n++){
for(var m =1;m <=n;m ++){
document.write ("<span>"+(n + "*" + m + "="+(m * n<10?(m * n) +" ":(m * n)+" "))+"</span>")
}
document.write("<br>");
}
</script>
<style>
body {
text-align: center;
}
span {
display: inline-block;
width: 100px;
height: 30px;
text-align: center;
line-height: 30px;
border: 1px solid black;
}
</style>
</head>
<body>
</body>
</html>
分享使用原生js写一个金字塔乘法表
最新推荐文章于 2024-08-12 22:28:07 发布