Initial commit

parents
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="js/jQuery.js"></script>
<script src="js/moment.js"></script>
<script src="js/index.js"></script>
<title>Document</title>
</head>
<body>
<input type="text" id="datepicker">
</body>
</html>
\ No newline at end of file
$(() => {
let calendar = () => {
let createCells = (table, firstDayOfMonth, daysOfMonth) => {
let day = 1;
for(let i = 0; i <= daysOfMonth / 7; i++) {
let row = $("<tr>");
for (let j = 1; j <= 7; j++) {
let cell;
if(i < 1 && j <= firstDayOfMonth) cell = ("<td> </td>");
else if(day <= daysOfMonth) cell = ("<td>" + day++ + "</td>");
else cell = ("<td> </td>")
row.append(cell);
}
table.append(row);
}
}
let now = moment();
let year = now.year(); //2020
let month = now.month(); //6
let daysOfMonth = now.month(month).daysInMonth(); //31
let firstDayOfMonth = now.month(month).startOf('month').day(); //3
const table = $('<table>' +
'<thead>' +
'<tr>' +
'<td>Su</td>' +
'<td>Mo</td>' +
'<td>Tu</td>' +
'<td>We</td>' +
'<td>Th</td>' +
'<td>Fr</td>' +
'<td>Sa</td>' +
'</tr>' +
'</thead>' +
'</table>');
$('body').append(table);
createCells(table, firstDayOfMonth, daysOfMonth);
}
$('#datepicker').on('click', calendar);
})
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment