用js写九九乘法表格,附带背景颜色
2024-09-01 21:55:35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- CSS样式 -->
<style>
* {
padding: 0;
margin: 0;
}
table {
width: 800px;
height: 350px;
margin: 100px auto;
text-align: center;
border-collapse: collapse;
}
table,
td {
border: 1px solid #000;
}
</style>
</head>
<body>
</body>
<script>
// 原始版
// document.write("<table>");
// var j = 1;
// while (j <= 9) {
// document.write("<tr>");
// var i = 1;
// while (i <= j) {
// document.write("<td>" + i + "*" + j + "=" + (i*j) + "</td>");
// i++;
// }
// document.write("</tr>");
// j++;
// }
// document.write("</table>");
//- - -分割线- - - -
// 附带奇偶数换色版
document.write("<table>");
for (var h = 1; h <= 9; h++) { //循环行数
// 奇偶数行换色
if (h % 2 == 1) {
document.write("<tr style='background:pink;'>");
} else {
document.write("<tr style='background:#6ff;'>");
}
for (var g = 1; g <= h; g++) { //循环列数,且列要小于等于行数
// 隔列变色
if (g % 2 == 1) {
document.write("<td style='background:pink;'>" + g + "*" + h + "=" + g * h + "</td>");
} else {
document.write("<td style='background:#6ff;'>" + g + "*" + h + "=" + g * h + "</td>");
}
}
document.write("</tr>");
}
document.write("<table>");
</script>
</html>
最新文章
- MySQL数据库的初始化mysql_install_db 【基础巩固】
- 07OC之KVC、KVO
- 【云计算】marathon集群如何升级?
- SQL Server 阻止了对组件 &#39;Ad Hoc Distributed Queries&#39; 的 STATEMENT&#39;OpenRowset/OpenDatasource&#39; 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 &#39;Ad Hoc Distributed Queries&#39;。有关启用 &#39;Ad Hoc Distributed Que
- postgresql 触发器
- hdoj 3785 寻找大富翁【优先队列+sort排序】
- BZOJ 1406: [AHOI2007]密码箱( 数论 )
- Windows8和MacOS10.9双系统安装及Mac经常使用软件安装--联想E49A
- 警惕Dictionary和SortedDictionary的顺序陷阱
- 自己编写服务启动脚本(一):functions文件详细分析和说明
- iOS中判断照片和相机权限
- Shiro源码分析之SecurityManager对象获取
- Atitit.如何文章写好 论文 文章 如何写好论文 技术博客
- 微信小程序---人脸识别(wx.startFacialRecognitionVerify)
- January 30th, 2018 Week 05th Tuesday
- 软Raid50制作
- Gitlab的SSH配置(linux和windows双版本)
- 如何禁用Firefox,chrome浏览器“不安全密码警告”
- nginx+php 开启https
- Appium1.6启动iOS真机
热门文章
- .NET Core 3.0 使用Nswag生成Api文档和客户端代码
- Redis 数据结构
- 网页解析之BeautifulSoup
- 依赖注入利器 - Dagger ‡
- 几种常见设计模式在项目中的应用<;Singleton、Factory、Strategy>;
- 正则grep 使用介绍
- 【SSL1455&;1456】 电子老鼠闯迷宫 &; 骑士游行
- 不用任何第三方,写一个RTMP直播推流器
- NSURLConnection发送GET请求
- SpringBoot-HelloWorld(三)