jquery Custom extension Method (ii)--html Calendar control

Source: Internet
Author: User

I. Overview

The last section of the jquery custom extension method, I have always wanted to do with jquery to write a small plug-in, work is also used in the calendar plug-in with jquery, their own thinking to build a wheel--HTML5 mobile phone Web Calendar control, nonsense not to say, first look at it

Very simple, the code is encapsulated in jquery, the web side only needs to be called;

Ii. jquery Custom Entity objects

jquery can be custom function functions, there is no entity object can be defined, inside the encapsulation method that? Query the data found, it is possible, not only to encapsulate the properties, you can also write their own methods, call the template code as follows:

$. Calenderdata = {         //Time Display button$ShowSelectData: Function () {$ ("#tcontrolretx"). Text (Tyeer +"years"+ Tmonth +"Month"+ Tday +"Day"); }        ,        //whether a leap year is interpreted$ISLeapYear: function (year) {if((Year%4) ==0) && (Year% -) !=0) || (Year% -) ==0)) {                return(true); }            Else {                return(false); }        },                //Initialize year$InitCalenderYeerData: Function (Yeerdata, curyear) {varyeerhtml =""; varNdatatime =NewDate ();//Current Time            varCurryear = Ndatatime.getfullyear ();//returns the year as a four-digit number from a Date object            varnowyear; Yeerhtml+ = Lidatamodel.format ("");  for(varIyee = Yeerdata; Iyee >=0; iyee--) {nowyear= Curryear-Iyee; if(Curyear = =nowyear) {yeerhtml+=Lisdatamodel.format (nowyear); }                Else{yeerhtml+=Lidatamodel.format (nowyear); }} yeerhtml+ = Lidatamodel.format (""); returnyeerhtml; }}

When calling, you only need to proceed as follows:

$. Calenderdata. $ShowSelectData ();

It is also convenient to call up. After encapsulation, jquery calls appear less cluttered.

jquery Custom extension Method (ii)--html Calendar control

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.