Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to make a simple Calendar with js+html

Shulou Source: shulou.com Published: 2022-05-31 13:02:52 09月24日 Update

This article mainly introduces the js+html how to make a simple calendar related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this js+html how to make a simple calendar article will have a harvest, let's take a look at it.

Code:

Untitled document * {margin: 0politics padding: 0} # calendar {width: 210pxposition: 100px auto;overflow: hidden;border: 1px solid # 000position: relative} # calendar h5 {text-align: center;margin-bottom: 10px} # calendar .a1 {position: absolute;top: 20pxleft: 20px;} # calendar .a2 {position: absolute;top: 20pxright: 20px;} # calendar .week {height: 30pxscape linelight height: 20pxbot borderhouse bottom: 1px solid # 000000 Margin-bottom: 10px} # calendar. Week li {float: left;width: 30pxposition height: 30pxten textreconcilion: center;list-style: none;} # calendar .dateList {overflow: hidden;clear: both} # calendar .dateList li {float: left;width: 30pxpolitical height: 30pxpolitical textAfter alignment: center;line-height: 30pxlistscapestyle: none;} # calendar .dateList .ccc {color: # ccc;} # calendar .dateList .red {background: # F90color: # fff } # calendar .dateList .sun {color: # f00;} $(function () {/ / necessary data / / Today of the year, month and Day The total number of days of this month; what day is the first day of this month? Var iNow=0; function run (n) {var oDate = new Date (); / / define time oDate.setMonth (oDate.getMonth () + n); / / set month var year = oDate.getFullYear (); / / year var month = oDate.getMonth (); / / month var today = oDate.getDate () / / calculate the number of days in the month var allDay = [31, 28, 31, 30, 31, 30, 31, 31, 31, 30, 31] [month]; / / determine the leap year if (month = = 1) {if (year% 4 = = 0 & year% 100! = 0 | | year% 400 = = 0) {allDay = 29;}} / / determine what day the first day of the month is oDate.setDate (1) / / adjust the time to the first day of this month var week = oDate.getDay (); / / read the day of the week / / console.log (week); $(".dateList"). Empty (); / / each time empty / / insert blank for (var I = 0; I < week; iTunes +) {$(".dateList"). Append ("");} / date insert into dateList for (var I = 1; I

Tags: Calendar production knowledge content date time week title article necessity code value number of days easy to operate data documents articles easy to understand more month Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Huawei OPPO Reno Linux Shulou Technology