JSFiddle - React, Tailwind, and code Playground
by tea4two
HTML
<table>
<tr>
<th>日</th>
<th>月</th>
<th>火</th>
<th>水</th>
<th>木</th>
<th>金</th>
<th>土</th>
</tr>
<tr id="insert">
</tr>
</table>
JavaScript
var date = new Date();
var firstDate = new Date( date.getFullYear() + '-' + (9+1) + '-1' );
console.log(firstDate.getDay(), date.getDay());
var firstDay = firstDate.getDay();
var lastDay = new Date(date.getFullYear(), (9+1),0).getDate();
var cells = Math.ceil((firstDay + lastDay) / 7) * 7;
console.log(cells);
var j = 1;
var tableHTML = '';
for(var i = 1; i <= cells; i++) {
tableHTML += '<td>';
if(i > firstDay && i <= (lastDay+firstDay)) {
tableHTML += j;
j++;
}
tableHTML += '</td>';
if(i % 7 === 0 && i < cells) {
tableHTML += '</tr><tr>';
}
}
console.log(tableHTML);