рони,
вот смотри
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body { }
.day {
border: 1px solid #ccc;
width: 30px;
line-height: 30px;
text-align: center;
margin: 1px;
background-color: #B0C4DE;
}
.month {
width: 238px;
height: 238px;
margin: ;
border: 1px solid #ccc;
}
.month tr:nth-child(n + 7) td.day{
background-color: #FF85C6;
}
.month tr:nth-child(1) th{
text-align: center;
}
</style>
</head>
<body>
<table class="month"></table>
<script>
var calendar = {
update: function(year, month) {
this.year = year;
this.month = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'][month];
var stepDay = new Date(year, month, 1);
stepDay.setDate(stepDay.getDate() - ((stepDay.getDay()||7) - 1));
var lastDay = new Date(stepDay);
lastDay.setDate(lastDay.getDate() + 41);
while (stepDay <= lastDay) {
this.days.push(stepDay.getDate());
stepDay.setHours(24);
}
},
render: function() {
var html = ['<tr>','<tr>','<tr>','<tr>','<tr>','<tr>','<tr>'];
for (var i = 0; i < this.days.length; i++) {
html[i % 7] += '<td class="day">' + this.days[i] ;
}
var title = '<tr><th colspan=7>' + this.month + ', ' + this.year;
this.element.innerHTML = title + html.join('');
}
};
var today = new Date(2019, 9),
thisYear = today.getFullYear(),
thisMonth = today.getMonth();
calendar.days = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
calendar.element = document.querySelector('.month');
calendar.update(thisYear, thisMonth);
calendar.render();
</script>
</body>
</html>
в следующем месяце пять недель, последний столбик лишний, как его обрезать?