Make a calendar with Html+css+javascript

Source: Internet
Author: User

  This is done after the effect. Not very beautiful, but also can be further improved.

  The HTML+CSS code is as follows:

<! DOCTYPE html>

  The JavaScript code is as follows:

    var nowdate=new Date (), Var nowyear=nowdate.getfullyear (), Var nowmonth=nowdate.getmonth () +1;//var month= (nowMonth <10? " 0 "+momth:month); var Text=document.getelementbyid (" Yearandmon "); text.innertext=nowyear+" year "+nowmonth+" month "; var MONTHDAYS1=[31,29,31,30,31,30,31,31,30,31,30,31]; var monthdays2=[31,28,31,30,31,30,31,31,30,31,30,31]function becomedate (nowyear,nowmonth) {var dt=new Date (NowYear, nowmonth-1,1) var firstday=dt.getday () var Table=document.getelementbyid ("table1"); var Monthdays=isrunnian () var Rows=5;var Cols=7;var K=1;for (var i=1;i<=rows;i++) {var tri=table.insertrow (); for (Var j=1;j<=7;j++) {var tdi= Tri.insertcell (); if (i==1&&i*j<firstday+1) tdi.innerhtml= ""; Else{if (K>monthdays[nowmonth-1]) break; tdi.innerhtml=k;k++;}}}} function Lastmon () {table1.innerhtml= ""; var Text=document.getelementbyid ("Yearandmon"); if (nowmonth>1) nowMonth= nowmonth-1;else{nowyear--;nowmonth=12;} text.innertext=nowyear+ "Year" +nowmonth+ "month"; Becomedate (Nowyear,nowmonth);} function Nextmon () {table1.innerhtml= ""; if (nowmonth<12) nowmonth=nowmonth+1;else{nowyear++;nowmonth=1;} var Text=document.getelementbyid ("Yearandmon"), text.innertext=nowyear+ "year" +nowmonth+ "month"; Becomedate (NowYear, Nowmonth);} function Isrunnian () {if (nowyear%4==0| | nowyear%400==0) &&nowyear%100!=0) return Monthdays1;elsereturn MonthDays2;} Becomedate (Nowyear,nowmonth);

 There are many shortcomings in the code, please advise.

Make a calendar with Html+css+javascript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.