jquery UI datepicker时间控件的使用

简介: 参考: http://api.jqueryui.com/datepicker/#method-show 英文 http://www.helloweba.com/view-blog-168.html  中文 http://jqueryui.

参考:

http://api.jqueryui.com/datepicker/#method-show 英文

http://www.helloweba.com/view-blog-168.html  中文

http://jqueryui.com/datepicker/

效果:

常用场合:

  1.输入框

  2.div

使用方法:

1.限制日期

$("#resultDiv").datepicker({
                onSelect: function (dateText, inst) {
                    //代码:选择日期后触发的事件
                },
                minDate: new Date(),//最小日期
                maxDate: new Date($("#DateLimit").val())//最大日期
            });

 2.中文

jQuery(function ($) {
        $.datepicker.regional['zh-CN'] = {
            closeText: '关闭',
            prevText: '<上月',
            nextText: '下月>',
            currentText: '今天',
            monthNames: ['一月', '二月', '三月', '四月', '五月', '六月',
                '七月', '八月', '九月', '十月', '十一月', '十二月'],
            monthNamesShort: ['', '', '', '', '', '',
                '', '', '', '', '十一', '十二'],
            dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
            dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
            dayNamesMin: ['', '', '', '', '', '', ''],
            weekHeader: '',
            dateFormat: 'yy-mm-dd',
            firstDay: 1,
            isRTL: false,
            showMonthAfterYear: true,
            yearSuffix: ''
        };
        $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
    });

 3.时间段查询用法

$(document).ready(function () {
         $('#SearchStartDT').datepicker({
            dateFormat: 'yy-mm-dd',
            onSelect: function (startDate) {
                var $startDate = $("#SearchStartDT");
                var $endDate = $('#SearchEndDT');
                var endDate = $endDate.datepicker('getDate');
                if (endDate < startDate) {
                    $endDate.datepicker('setDate', startDate - 3600 * 1000 * 24);
                }
                $endDate.datepicker("option", "minDate", startDate);
            }
        });
        $('#SearchEndDT').datepicker({
            dateFormat: 'yy-mm-dd',
            onSelect: function (endDate) {
                var $startDate = $("#SearchStartDT");
                var $endDate = $('#SearchEndDT');
                var startDate = $startDate.datepicker("getDate");
                if (endDate < startDate) {
                    $startDate.datepicker('setDate', startDate + 3600 * 1000 * 24);
                }
                $startDate.datepicker("option", "maxDate", endDate);
            }
        });
        $("#SearchStartDT").datepicker("option", "maxDate", new Date());
        $("#SearchEndDT").datepicker("option", "maxDate", new Date());
    });

4.只显示月份

 多种解决方法:http://www.itstrike.cn/Question/c7c3214d-0a6b-4d89-8b4f-f7753763e927.html

 

 

 

 

 

 

相关文章
|
1月前
|
C# 开发者 Windows
基于Material Design风格开源、易用、强大的WPF UI控件库
基于Material Design风格开源、易用、强大的WPF UI控件库
|
2月前
|
算法 API C++
【Qt UI】QT 窗口/控件置顶方法详解
【Qt UI】QT 窗口/控件置顶方法详解
78 0
|
2月前
|
算法 前端开发 C++
【Qt UI相关】Qt设置窗体或控件的背景色透明
【Qt UI相关】Qt设置窗体或控件的背景色透明
30 0
|
2月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
32 0
|
2月前
|
JavaScript 前端开发 开发者
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
17 0
|
2月前
|
XML 存储 数据格式
SAP UI5 控件 customData 属性的应用介绍
SAP UI5 控件 customData 属性的应用介绍
35 0
|
2月前
|
XML 前端开发 JavaScript
深入介绍 UI5 框架里 Smart Field 控件的工作原理
深入介绍 UI5 框架里 Smart Field 控件的工作原理
19 0
|
2月前
|
XML 开发框架 前端开发
浅谈 Angular 和 UI5 这两种前端框架里控件 ID 的设计思路差异
浅谈 Angular 和 UI5 这两种前端框架里控件 ID 的设计思路差异
18 0
|
3月前
|
开发框架 容器
SAP UI5 控件的 aggregation 的概念解析
SAP UI5 控件的 aggregation 的概念解析
37 0
|
4月前
|
API C# 开发者
一款开源免费美观的WinForm UI控件库
一款开源免费美观的WinForm UI控件库
310 9

相关课程

更多