Learn to write js Calender calendar controls together, jscalender calendar controls

Source: Internet
Author: User

Learn to write js Calender calendar controls together, jscalender calendar controls

I recently read some functions about js date and suddenly thought of the calendar control. So I tried to write one. As a background programmer, I have a limited level, let's take a look at the example I wrote and learn and make progress together!

First, a common date function:

Date (year, month, day)

Var date = new Date ();

Get year

Var year = this. date. getFullYear ();

Obtain the month. Here is the monthly index, so we need to add 1 more.

Var month = this. date. getMonth () + 1;

Obtain the number of the current day

Var day = this. date. getDate ();

Returns the day of the week. 0. Sunday 1. Monday 2. Tuesday 3. Wednesday 4. Thursday 5. Friday 6. Saturday.

Var week = this. date. getDay ();

Obtain the number 1 of the week in the current month.

 var   getWeekDay=function(year,month,day){      var date=new Date(year,month,day);      return date.getDay();      }   var  weekstart= getWeekDay(this.year, this.month-1, 1)

Obtain the number of days in the current month

var getMonthDays=function(year,month){      var date=new Date(year,month,0);      return date.getDate();    }var  monthdays= this.getMonthDays(this.year,this.month);

Well, we have used so many parameters. The following are some operations and judgments on the day of the week corresponding to the date, and dynamic tag splicing. The example I wrote is directly sent below:

:

<Html> <meta http-equiv = "content-type" content = "text/html; charset = UTF-8 "> 

The Code was modified again and the View table was changed to div to solve the read-only problem of IE tableinnerHTML. In addition, options is added for configuration.
The code above has a simple description, and the function is the most basic. If more in-depth work can be done, we hope this article will give you some inspiration.

Articles you may be interested in:
  • Php + javascript calendar controls
  • JS calendar control (blue)
  • One simple calendar Control for JS Learning
  • Javascript to implement the calendar control (year, month, and day close button)
  • Modify js Calendar controls to be compatible with IE9/Google/Firefox
  • Use of Calender in ASP. NET notes
  • Simple JS calendar control instance code
  • Php calender (calendar) Two version code examples (solving the 2038 problem)
  • Php Calender (calendar) code sharing
  • Js Calender controls

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.