An analysis of the DatePicker component of jquery UI

Source: Internet
Author: User
Tags i18n

Today, you plan to add a calendar to your blog to make it easier for users to see dates. Google took a lap and finally decided to use the DatePicker widget of the jquery UI. There are three reasons: DatePicker the use of a simple configuration, a few lines of code to get a simple calendar, with detailed documentation and reference materials, extensibility, and support of the custom interface.

The first is the introduction of dependent files. You can use online resources, or you can download them locally via bower. I downloaded it to a public folder, so at the beginning of the code, add the tag:

    <Linkrel= "stylesheet"href= "Public/lib/jquery-ui/themes/flick/jquery-ui.css">Themes folder has 25 sub-folders, the introduction of jquery-ui.css under each folder, you can use different calendar background style
<Scriptsrc= "Public/lib/jquery/dist/jquery.js"></Script> <Scriptsrc= "Public/lib/jquery-ui/jquery-ui.min.js"></Script> <Scriptsrc= "Public/lib/jquery-ui/ui/i18n/datepicker-zh-cn.js"></Script> //localization, the introduction of i18n under the various files, you can make the calendar display as the appropriate language, by default is English

Easy to get started, as an example of an embedded calendar:

<class= "DatePicker"></div>
<script>
$ (". DatePicker"). DatePicker ();
</script>

You can get a simple flick-style calendar, and the contents of the calendar will be displayed in Chinese instead of English. There are several more commonly used configurations that we use to complete a more complete calendar:

<Divclass= "DatePicker"></Div><Script>$(". DatePicker"). DatePicker ({changeyear:true,//whether to display an optional year in the form of a drop-down menu on the calendar, allowing users to jump changemonth between different years:true,//whether to display the optional month showbuttonpanel on the calendar as a drop-down menu:true //displays a "Today" button for selecting the day date });</Script>

As follows:

An analysis of the DatePicker component of jquery UI

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.