jquery九九乘法口诀表
时间: 2023-08-05 19:04:00 浏览: 87
很高兴回答你的问题!以下是使用 jQuery 实现九九乘法口诀表的示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
table {
border-collapse: collapse;
}
th, td {
border: 1px solid black;
padding: 5px;
text-align: center;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th></th>
<script>
for (var i = 1; i <= 9; i++) {
document.write('<th>' + i + '</th>');
}
</script>
</tr>
</thead>
<tbody>
<script>
for (var i = 1; i <= 9; i++) {
document.write('<tr><th>' + i + '</th>');
for (var j = 1; j <= 9; j++) {
document.write('<td>' + i * j + '</td>');
}
document.write('</tr>');
}
</script>
</tbody>
</table>
</body>
</html>
```
这段代码使用了 jQuery 库来简化 DOM 操作,它会生成一个包含九九乘法口诀表的 HTML 表格。你可以将上面的代码保存为一个 HTML 文件并在浏览器中打开,就可以看到生成的九九乘法口诀表。希望对你有所帮助!如果还有其他问题,请随时提问。