//學習筆記javascript
首先要去把相對應的jquery-ui.min.css和jquery-ui.min.js和images下載下來css
(完整包以下:http://download.jqueryui.com/download)html
而後引入到你的項目中java
在使用的時候只須要jquery
<script> $(document).ready(function() { $("#demoInput").datepicker(); }); </script>
而後點擊這個ID爲demoInput的元素時,就會彈出來datepicker選擇器,選擇後值會添加到這個元素的val中學習
想要下拉選擇年份和月份?ui
$( "#demoInput" ).datepicker({changeYear:true,changeMonth:true});
想要顯示爲中文?orm
$.datepicker.regional["zh-CN"] = { closeText: "關閉", prevText: "<上月", nextText: "下月>", currentText: "今天", monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], dayNames: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], dayNamesShort: ["週日", "週一", "週二", "週三", "週四", "週五", "週六"], dayNamesMin: ["日", "一", "二", "三", "四", "五", "六"], weekHeader: "周", dateFormat: "yy-mm-dd", firstDay: 1, isRTL: !1, showMonthAfterYear: !0, yearSuffix: "年" } $.datepicker.setDefaults($.datepicker.regional["zh-CN"]); $( "#demoInput" ).datepicker({ showOtherMonths: true,selectOtherMonths: true});
想要更改日期顯示的格式?htm
$( "#demoInput" ).datepicker({dateFormat: 'yy-mm-dd'});
以上,這些只是最簡陋的但能實現功能的腳本,獲取更多功能和設置,能夠參考(http://www.runoob.com/jqueryui/example-datepicker.html)或者官方說明文檔~~blog