解决jquery的datepicker的本地化以及Today问题
2016-06-21 11:31
561 查看
1、本地化 可以直接加载文件,也可以直接在script后面加入如下语句
2:默认情况下,在该控件点击“today”按钮是直接调到当前日期的附近,如果需要选择当前日期,还需要我们自己手动点击,有的时候我们需要单击Today (今天) 直接在input 中显示日期,而不是跳转到今天的地方而需要用户再次点击日期修改方法很简单,在script中添加这段代码:
现在点击“today”按钮就可以自动在输入框中写入当前日期了。
$.datepicker._gotoToday = function (id) {
var target = $(id);
var inst = this._getInst(target[0]);
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
}
else {
var date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
this._setDateDatepicker(target, date);
this._selectDate(id, this._getDateDatepicker(target));
}
this._notifyChange(inst);
this._adjustDate(target);
}
转自:
http://www.jb51.net/article/30372.htm
http://www.jb51.net/article/30372.htm
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']); });
2:默认情况下,在该控件点击“today”按钮是直接调到当前日期的附近,如果需要选择当前日期,还需要我们自己手动点击,有的时候我们需要单击Today (今天) 直接在input 中显示日期,而不是跳转到今天的地方而需要用户再次点击日期修改方法很简单,在script中添加这段代码:
jQuery.datepicker._gotoToday = function (id) { var target =jQuery(id); var inst = this._getInst(target[0]); if (this._get(inst, 'gotoCurrent') && inst.currentDay) { inst.selectedDay = inst.currentDay; inst.drawMonth = inst.selectedMonth = inst.currentMonth; inst.drawYear = inst.selectedYear = inst.currentYear; } else { var date = new Date(); inst.selectedDay = date.getDate(); inst.drawMonth = inst.selectedMonth = date.getMonth(); inst.drawYear = inst.selectedYear = date.getFullYear(); this._setDateDatepicker(target, date); this._selectDate(id, this._getDateDatepicker(target)); } this._notifyChange(inst); this._adjustDate(target); }
现在点击“today”按钮就可以自动在输入框中写入当前日期了。
$.datepicker._gotoToday = function (id) {
var target = $(id);
var inst = this._getInst(target[0]);
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
inst.selectedDay = inst.currentDay;
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
inst.drawYear = inst.selectedYear = inst.currentYear;
}
else {
var date = new Date();
inst.selectedDay = date.getDate();
inst.drawMonth = inst.selectedMonth = date.getMonth();
inst.drawYear = inst.selectedYear = date.getFullYear();
this._setDateDatepicker(target, date);
this._selectDate(id, this._getDateDatepicker(target));
}
this._notifyChange(inst);
this._adjustDate(target);
}
转自:
http://www.jb51.net/article/30372.htm
http://www.jb51.net/article/30372.htm
相关文章推荐
- Android自定义DataTimePicker实例代码(日期选择器)
- js实现精确到秒的日期选择器完整实例
- Android时间选择器、日期选择器实现代码
- js实现精确到秒的日期选择器完整实例
- iOS 开发时间选择器datePicker
- iOS开发(OC)——日期选择器
- Web滑动日期选择器(仿iOS)
- 自定义简单的UIDatePicker
- 简单DatePickerDialgog 例子、生日限制、加取消按钮
- 使用第三方WheelView制作日期选择器
- Android时间选择器和日期选择器的使用注意
- Android简易日期选择
- Bootstrap 插件【四】
- 与moment.js整合使用的javascript日期选择期 - Pikaday
- Android零基础入门第57节:日期选择器DatePicker和时间选择器TimePicker
- 微信小程序开发之选择器 时间选择器 日期选择器 地区选择器
- Android自定义简易时间选择器
- 基于wheelview实现常用的选择器
- DataPicker的详细讲解
- ios自定义日期、时间、城市选择器