แสดงเดือนและปีในปฏิทินด้วย JavaScript
ในบทเรียนก่อนหน้านี้ เราสร้างปฏิทินตามตัวอย่างในบทเรียนแรกมาด้วยกัน ทีนี้มาปรับปรุงมันให้ดีขึ้นกัน
เริ่มต้น ลองทำให้เหนือปฏิทินแสดงเดือนและปีปัจจุบันกัน เริ่มต้นด้วยการเปลี่ยนแปลงโค้ด HTML:
<div id="parent">
<div id="calendar">
<div class="info">ม.ค. 2020</div>
<table>
<thead>
<tr>
<th>จ.</th>
<th>อ.</th>
<th>พ.</th>
<th>พฤ.</th>
<th>ศ.</th>
<th>ส.</th>
<th>อา.</th>
</tr>
</thead>
<tbody class="body"></tbody>
</table>
</div>
</div>
และเปลี่ยนแปลงโค้ด CSS ด้วย:
#parent {
text-align: center;
}
#calendar {
display: inline-block;
}
#calendar td, #calendar th {
padding: 10px;
border: 1px solid black;
text-align: center;
}
#calendar .info {
text-align: center;
}
จงปรับปรุงการแสดงเดือนและปีปัจจุบันตามที่อธิบายไว้