This commit is contained in:
赵鑫 2022-09-03 14:56:14 +08:00
parent f338ddac43
commit c084648b9b

View File

@ -33,7 +33,7 @@
</header> </header>
<section class="课程表"> <section class="课程表">
<img src="images/ryan.png" height="80px"> <img src="images/ryan.png" height="80px">
<span class="date">Today is <span id="weekday1"></span>.</span> <span class="date">今天是<span id="weekday1"></span></span>
<table> <table>
<thead> <thead>
<tr> <tr>
@ -107,7 +107,7 @@
</section> </section>
<section class="课程表"> <section class="课程表">
<header> <header>
<span class="date">今天是周<span id="weekday2"></span></span> <span class="date">今天是周<span id="weekday2"></span></span>
<img src="images/little_cat.png" height="80px"> <img src="images/little_cat.png" height="80px">
</header> </header>
<table> <table>
@ -182,11 +182,12 @@
</table> </table>
</section> </section>
<script> <script>
const today = new Date() const now = new Date()
const weekday = today.getDay() const weekday = now.getDay()
const day = "日一二三四五六"[weekday] const day = "日一二三四五六"[weekday]
document.querySelector("#weekday1").innerText = today.toLocaleDateString() const date = `${now.getFullYear()}年${now.getMonth() + 1}月${now.getDate()}日`
document.querySelector("#weekday2").innerText = day document.getElementById("weekday1").innerText = date
document.getElementById("weekday2").innerText = day
if (weekday > 0 && weekday < 6) if (weekday > 0 && weekday < 6)
document.querySelectorAll(`tr td:nth-child(${weekday + 1})`).forEach(cell => { document.querySelectorAll(`tr td:nth-child(${weekday + 1})`).forEach(cell => {
cell.style.color = "#ff7" cell.style.color = "#ff7"