九九乘法表
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>九九乘法表</title>
<style>
body {
color: #333;
}
table {
900px;
table-layout: fixed; //
列宽由表格宽度和列宽度设定。 |
border-collapse: collapse;
}
td {
border: 1px solid #ccc;
padding: 10px;
}
</style>
</head>
<body>
<h1>九九乘法表</h1>
<hr>
<script>
//JavaScript生成九九乘法表
document.write('<table>');
//循环 输出tr 行
for (var i = 1; i <= 9; i ++) {
document.write('<tr>');
//输出 td 单元格
for (var j = 1; j <= i; j ++) {
document.write(`<td>${i}×${j} = ${i * j}</td>`);
}
document.write('</tr>');
}
document.write('</table>');
</script>
</body>
</html>