设置jQuery-ui插件datepicker的参数使用详解

datepicker  时间:2021-01-29  阅读:()

jQuery-ui插件datepicker的参数使用详解

·概述

日期选择插件是一个配置灵活的插件你可以定义它的展示方式包括日期格式、语言、限制选择日期范围、添加相关按钮以及其它导航等。

同时你还可以通过键盘控制它page up/down-上一月、下一月ctrl+page up/down-上一年、下一年ctrl+home-当前月或最后一次打开的日期c trl+left/right -上一天、下一天ctrl+up/down-上一周、下一周enter-确定选择日期ctrl+end-关闭并清除已选择的日期escape-关闭并取消选择

实用功能

$.datepic ker.s etDefaults( s ettings ) -全局设置日期选择插件的参数.

$.datepicker.formatDate(format,date, s ettings ) -格式化显示的日期字符串

$.datepic ker.is o 8601 Week(date) -给出一个日期确实他是一年中的第几周

$.datepicker.pars eDate(format,value, s ettings ) -按照指定格式获取日期字符串

日期格式d-每月的第几天(没有前导零)dd-每月的第几天(两位数字)o-一年中的第几天(没有前导零)oo-一年中的第几天(三位数字)

D-day name short

DD-day name longm-月份(没有前导零)mm-月份(两位数字)

M-month name short

MM-month name longy-年份(两位数字)yy-年份(四位数字)

@-Unix时间戳(从01/01/1970开始)

' .. .' -文本

' ' -单引号

其它 -文本

其它标准日期格式:

ATOM- 'yy-mm-dd' (Same as RFC 3339/ISO 8601)

COOKIE- 'D,dd M yy'

I S O_8601 - 'yy-mm-dd'

RFC_822- 'D,dMy'

RFC_850- 'DD,dd-M-y'

RFC_1036- 'D,dMy

RFC_1123 - 'D,d M yy'

RFC_2822- 'D,d M yy'

RSS- 'D,d M y'

T I MESTAMP- '@'

W3 C- 'yy-mm-dd'

·参数参数名:参数类型:默认值altF ield:Strin g: ' '

将选择的日期同步到另一个域中配合altFormat可以显示不同格式的日期字符串。初始 $('.s elector').datepic ker({altF ield: '#ac tualDate' });

获取 var altField=$('.s elector').datepicker('option', 'altField');

设置 $('.s elector').datepic ker('option', 'altField', '#ac tualDate');altF ormat :String: ' '

当设置了altF ie ld的情况下显示在另一个域中的日期格式。

初始 $('.s elector').datepic ker({altFormat: 'yy-mm-dd' });

获取 var altFormat=$(' .selector').datepicker('option', 'altFormat');

设置 $('.s elector').datepic ker('option', 'altFormat', 'yy-mm-dd');appendT ext :String: ' '

在日期插件的所属域后面添加指定的字符串。

初始 $('.s elector').datep ic ker({appendT ext: '(yyyy-mm-dd)' });

获取 var appendText=$(' .selector').datepicker('option', 'appendText');

设置 $('.s elector').datepic ker('option', 'appendT ext', '(yyyy-mm-dd)');buttonImag e :S tring: ' '

设置弹出按钮的图片如果非空则按钮的文本将成为alt属性不直接显示。初始 $('.s elector').datepic ker({buttonImage: '/image s/datepic ker.gif' });

获取 var buttonImage=$('.s elector').datepic ker('option', 'buttonImage');

设置 $('.selec tor').datepic ker('option', 'buttonImage', '/images/datepic ker.gif');buttonImageOnly:Boole an:fals e

Set to true to place an image after the field to use as the trigg er without it appea ring on abutto n.

初始 $('.s elector').datepic ker({buttonImageOnly: true });

获取 var buttonImageOnly=$('.s elector').datepicker('option', 'buttonImageOnly');设置 $('.s elector').datepic ker('option', 'buttonImageOnly', true);buttonT ext :Strin g: ' .. .'

设置触发按钮的文本内容。

初始 $('.s elector').datepicker({buttonText: 'Choos e' });

获取 var buttonText=$(' .s elector').datepicker('option', 'buttonText');

设置 $('.s elector').datepicker('option', 'buttonText', 'Choose');c hangeMonth:Boole an:fals e

设置允许通过下拉框列表选取月份。

初始 $('.s elector').datepic ker({changeMonth: true });

获取 var changeMonth=$(' .s elector').datepicker('option', 'changeMonth');

设置 $('.s elector').datepicker('option', 'changeMonth', true);c hangeYear :Boole an:fals e

设置允许通过下拉框列表选取年份。

初始 $('.s elector').datepicker({changeYear: true });

获取 var changeYear=$('.selector').datepicker('option', 'changeYear');

设置 $('.s elector').datepicker('option', 'changeYear', true);c loseTextType:StringDefault: 'Done'

设置关闭按钮的文本内容此按钮需要通过showButtonPanel参数的设置才显示。

初始 $('.s elector').datepicker({c los eText: 'X' });

获取 var c loseText=$(' .s elector').datepicker('option', 'c los eText');

设置 $('.selector').datepicker('option', 'closeText', 'X');c onstrainInput :Boole an: true

如果设置为true则约束当前输入的日期格式。

初始 $('.s elector').datepic ker({c onstrainInput:fals e });

获取 var c onstrainInput=$('.s elector').datepicker('option', 'c onstrainInput');

设置 $('.s elector').datepic ker('option', 'c onstrainInput', fals e);c urrentT ext :String: 'T oday'

设置当天按钮的文本内容此按钮需要通过showButtonPanel参数的设置才显示。

初始 $('.s elector').datepicker({currentText: 'Now' });

获取 var currentText=$(' .s elector').datepicker('option', 'currentText');

设置 $('.s elector').datepicker('option', 'currentText', 'Now');dateFormat :String: 'mm/dd/yy'

设置日期字符串的显示格式。

初始 $('.s elector').datepic ker({dateFormat: 'yy-mm-dd' });

获取 var dateFormat=$('.selector').datepicker('option', 'dateFormat');

设置 $('.s elector').datepicker('option', 'dateFormat', 'yy-mm-dd');dayNames : Array : [ 'Sunday', 'Monday', 'Tues day', 'Wednes day', 'Thursday', 'Friday','S aturday']

设置一星期中每天的名称从星期天开始。此内容用于dateFormat时显示以及日历中当鼠标移至行头时显示。

初始 $('.s elector').datepicker({ dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi','Vendredi', 'Samedi'] });

获取 var dayNames=$(' .selector').datepicker('option', 'dayNames');

设置 $('.s elector').datepicker('option', 'dayNames', ['Dimanche', 'Lundi', 'Mardi', 'Mercredi','Jeudi', 'Vendredi', 'S amedi']);d]

设置一星期中每天的缩语从星期天开始此内容用于dateFormat时显示以前日历中的行头显示。

初始 $('.selector').datepicker({dayNamesMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'] });

获取 var dayNamesMin=$(' .selector').datepicker('option', 'dayNamesMin');

设置 $(']);dayNames Short :Array: ['Sun', 'Mon', 'Tue' , 'Wed', 'Thu', 'Fri', 'Sat']

设置一星期中每天的缩语从星期天开始此内容用于dateFormat时显示以前日历中的行头显示。

初始 $(''Sam'] });

获取 var dayNames Short=$(' .selector').datepicker('option', 'dayNames Short');

设置$('Sam']);defaultD ate :Date,Numb er,S tring:null

设置默认加载完后第一次显示时选中的日期。可以是Date对象或者是数字从今天算起例如+7或者有效的字符串('y'代表年, 'm'代表月, 'w'代表周, 'd'代表日,例如 '+1m+7d')。

初始 $('.s elector').datepicker({defaultDat e:+7});

获取 var defaultDate=$(' .selector').datepicker('option', 'defaultDate');

设置 $('.selector').datepicker('option', 'defaultDat e',+7);dur ation:S tring,Numb er : 'normal'

设置日期控件展开动画的显示时间可选是"slow", "normal", "fast" ' '代表立刻数字代表毫秒数。

初始 $('.selector').datepicker({duration: 'slow' });

获取 var duration=$('.selector').datepicker('option', 'duration');

设置 $('.selector').datepicker('option', 'duration', 'slow');fir s tD ay:Numb er :0

设置一周中的第一天。星期天为0星期一为1 以此类推。

初始 $('.selector').datepicker({firstDay: 1 });

获取 var firstDay=$('.selector').datepicker('option', 'firstDay');

设置 $('.selector').datepicker('option', 'firstDay', 1);goto Current :Boole an:fals e

如果设置为true则点击当天按钮时将移至当前已选中的日期而不是今天。

初始 $('.s elector').datepic ker({gotoCurrent: true });

获取 var gotoCurrent=$('.s elector').datepicker('option', 'gotoCurrent');

设置 $('.s elector').datepic ker('option', 'gotoCurrent', true);hideIfNoPrevNext :Boole an:fals e

设置当没有上一个/下一个可选择的情况下 隐藏掉相应的按钮。 默认为不可用

初始 $('.s elector').datepicker({hideIfNoPrevNext: true });

获取 var hideIfNoPrevNext=$(' .selector').datepicker('option', 'hideIfNoPrevNext');

设置 $('.s elector').datepicker('option', 'hideIfNoPrevNext', true);is RTL:Boole an:fals e

如果设置为true则所有文字是从右自左。

初始 $('.s elector').datepic ker({ isRTL: true });

获取 var isRTL=$('.selector').datepicker('option', 'isRTL');

设置 $('.s elector').datepicker('option', 'isRTL', true);maxD ate :D ate,Numb er,S tring:nul l

设置一个最大的可选日期。可以是Date对象或者是数字从今天算起例如+7或者有效的字符串('y'代表年, 'm'代表月, 'w'代表周, 'd'代表日,例如 '+1m+7d')。

初始 $('.selector').datepicker({maxDate: '+1 m+1w' });

获取 var maxDate=$('.selector').datepicker('option', 'maxDate');

设置 $('.selector').datepicker('option', 'maxDate', '+1 m+1w');minD ate :D ate,Numb er,S tring:null

设置一个最小的可选日期。可以是Date对象或者是数字从今天算起例如+7或者有效的字符串('y'代表年, 'm'代表月, 'w'代表周, 'd'代表日,例如 '+1m+7d')。

初始 $('.selector').datepicker({minDate:new Date(2007, 1 - 1, 1) });

获取 var minDate=$(' .selector').datepicker('option', 'minDate');

设置 $('.selector').datepicker('option', 'minDate',new Date(2007, 1 - 1, 1));monthNames :Array : [ 'J anuary', 'F ebruary', 'Marc h', 'April', 'May', 'June', 'July', 'August','S eptember', 'Oc tober', 'November', 'Dec ember']

设置所有月份的名称。

初 始  $(' .s elector').datepicker( monthNames:['J anuar'mb er']});

获取 var monthNames=$('.selector').datepicker('option', 'monthNames');

设 置  $(' .s elector').datepicker('option', ' monthNames',['J anuar'mb er']);monthNamesShort :Arr'Dec']

设置所有月份的缩写。

初 始  $('.s elector').datepicker( monthNames Short:['Jan'

获取 var monthNames Short=$(' .selector').datepicker('option', 'monthNames Short');

设 置  $(' .selector').datepicker('option', 'monthNames Short',['Jan'navigationAsDateFormat :Boole an:fals e

如果设置为true则formatDate函数将应用到prevT ext,nextText和currentT ext的值中显示例如显示为月份名称。

初始 $('.s elector').datepicker({navigationAsDateFormat: true });

获 取  var navig ationAsDateFormat = $(' .selector').datepicker('option','navigation AsDateFormat');

设置 $('.selector').datepicker('option', 'navigationAsDateFormat', true);nextText :String: 'Next'

设置“下个月”链接的显示文字。

初始 $('.s elector').datepic ker({nextText: 'Later' });

获取 var nextText=$('.s elector').datepicker('option', 'nextText');

设置 $('.s elector').datepic ker('option', 'nextText', 'Later');numb er O fMonth s :Numb er,Arr ay: 1

设置一次要显示多少个月份。如果为整数则是显示月份的数量如果是数组则是显示的行与列的数量。

初始 $('.s elector').datepic ker({numberOfMonths: [2,3] });

获取 var numberOfMonths=$(' .s elec tor').datepic ker('option', 'numberOfMonths');

设置 $('.s elector').datepic ker('option', 'numberOfMonths', [2,3]);prevText :Strin g: 'Prev'

设置“上个月”链接的显示文字。

初始 $('.s elector').datepicker({prevText: 'Earli er' });

获取 var prevText=$('.selector').datepicker('option', 'prevText');

设置 $('.s elector').datepicker('option', 'prevText', 'Earli er');s hortYearC utoff:S tring,Number : '+10'

设置截止年份的值。如果是0-99的数字则以当前年份开始算起如果为字符串则相应的转为数字后再与当前年份相加。当超过截止年份时则被认为是上个世纪。

初始 $('.s elector').datepicker({ shortYearCutoff:50});

获取 var shortYearCutoff=$('.selector').datepicker('option', 'shortYearCutoff');

设置 $('.selector').datepicker('option', 'shortYearCutoff',50);showAnim:String: 'show'

设置显示、隐藏日期插件的动画的名称。

初始 $('.selector').datepicker({ showAnim: 'fold' });

获取 var showAnim=$(' .selector').datepicker('option', 'showAnim');

设置 $('.selector').datepicker('option', 'showAnim', 'fold');showButtonPanel :Boole an:fals e

设置是否在面板上显示相关的按钮。

初始 $('.s elector').datepicker({ showButtonPanel: true });

获取 var showButtonPanel=$('.selector').datepicker('option', 'showButtonPanel');设置 $('.s elector').datepic ker('option', 'showButtonPanel', true);s how CurrentAtP o s :Numb er :0

设置当多月份显示的情况下 当前月份显示的位置。 自顶部/左边开始第x位。初始 $('.s elector').datepic ker({ show CurrentAtPo s:3 });

获取 var show CurrentAtPos=$('.s elector').datepicker('option', 'show CurrentAtPo s');设置 $('.selector').datepicker('option', 'show CurrentAtPo s', 3);show MonthAfterYear :Boole an:fals e

是否在面板的头部年份后面显示月份。

初始 $('.s elector').datepic ker({ showMonthAfterYear: true });

获取 var showMonthAfterYear=$('.s elector').datepicker('option', 'showMonthAfterYear');设置 $('.s elector').datepic ker('option', 'showMonthAfterYear', true);showOn:String: 'focus'

设置什么事件触发显示日期插件的面板可选值 foc us,button,both

初始 $('.selector').datepicker({ showOn: 'both' });

获取 var showOn=$('.selector').datepicker('option', 'showOn');

设置 $('.selector').datepicker('option', 'showOn', 'both');showOptions :Options : {}

如果使用showAnim来显示动画效果的话可以通过此参数来增加一些附加的参数设置。

初始 $('.selector').datepicker({ showOptions: {direction: 'up' });

获取 var showOptions=$('.selector').datepicker('option', 'showOptions');

设置 $('.selector').datepicker('option', 'showOptions', {direction: 'up');show OtherMonths :Boole an:fals e

是否在当前面板显示上、下两个月的一些日期数不可选。

初始 $('.s elector').datepic ker({ show OtherMonths: true });

获取 var showOtherMonths=$(' .s elector').datepicker('option', 'showOtherMonths');设置 $('.s elector').datepic ker('option', 'show OtherMonths', true);s tepMonths :Numb e r : 1

当点击上/下一月时一次翻几个月。

初始 $('.s elector').datepicker({ stepMonths:3 });

获取 var stepMonths=$(' .s elector').datepicker('option', 'stepMonths');

设置 $('.s elector').datepic ker('option', 'stepMonths', 3);yearRange :String: '-10:+10'

控制年份的下拉列表中显示的年份数量可以是相对当前年(-nn:+nn)也可以是绝对值(-nnnn:+nnnn)

初始 $('.selector').datepicker({yearRange: '2000:2010' });

获取 var yearRange=$('.selector').datepicker('option', 'yearRange');

设置 $('.selector').datepicker('option', 'yearRange', '2000:2010');

·事件beforeShow:func tion(input)

在日期控件显示面板之前触发此事件并返回当前触发事件的控件的实例对象。

初始 $('.s elector').datepicker({beforeShow:function(input) { .. . } });beforeShowDay:function(date)

在日期控件显示面板之前每个面板上的日期绑定时都触发此事件参数为触发事件的日期。调用函数后必须返回一个数组 [0]此日期是否可选(true/fals e) [1]此日期的C S S样式名称(""表示默认) [2]当鼠标移至上面出现一段提示的内容。

初始 $('.selector').datepicker({beforeShowDay:function(date) { .. . } });onChangeMonthYe ar :func tion(year,month, inst)

当年份或月份改变时触发此事件参数为改变后的年份月份和当前日期插件的实例。

初始 $('.s elector').datepic ker({onChangeMonthYe ar:func tion(year,month, inst) { .. . } });onClose :function(dateText, inst)

当日期面板关闭后触发此事件无论是否有选择日期参数为选择的日期和当前日期插件的实例。

初始 $('.selector').datepicker({onClos e:function(dateText, inst) { . .. } });onSelect :function(dateText, inst)

当在日期面板选中一个日期后触发此事件参数为选择的日期和当前日期插件的实例。

$(' .selector').datepicker({onSelect:function(dateText, inst) { . .. } });

方法destory

从元素中移除拖拽功能。

用法 .datepic ker( 'destroy' )dis ab le

禁用元素的拖拽功能。

用法 .datepic ker( 'dis able' )enable

启用元素的拖拽功能。

用法 .datepic ker( 'enable' )option

获取或设置元素的参数。

用法 .datepic ker( 'option' ,optionName, [value] )dialo g

在dial og插件中打开一个日期插件。

用法 .datepic ker( 'dialog' ,dateText , [onS elec t] , [s ettings] , [pos] )is Dis abled

确实日期插件是否已被禁用。

用法 .datepic ker( 'is Dis abled' )hide

隐藏关闭之前已经打开的日期面板。

用法 .datepicker( 'hide' , [speed] )show

.datepicker( 'show' )

显示日期插件。

用法 .datepicker( 'show' )getDate

返回当前日期插件选择的日期。

用法 .datepic ker( 'getDate' )s etDate

设置日期插件当前的日期。 date参数可以是数字从今天算起例如+7或者有效的字符串('y'代表年, 'm'代表月, 'w'代表周, 'd'代表日,例如 '+1 m+7 d') null表示当天。

用法 .datepicker( 's etDate' ,date)

非常欢迎您到我的个人网站<<PHP天地>>上交流学习提出您的宝贵建议

网址 http://www.p hp td.c o m/

Friendhosting四五折促销,VPS半年付7.5欧元起

Friendhosting发布了针对“系统管理日”(每年7月的最后一个星期五)的优惠活动,针对VPS主机提供55%的优惠(相当于四五折),支持1-6个月付款使用,首付折扣非永久,优惠后最低套餐首半年7.18欧元起。这是一家保加利亚主机商,成立于2009年4月,商家提供VDS和独立服务器租用等,数据中心目前可选美国洛杉矶、保加利亚、乌克兰、荷兰、拉脱维亚、捷克和波兰等8个地区机房。下面以最低套餐为例...

10gbiz:香港/洛杉矶CN2直连线路VPS四折优惠,直连香港/香港/洛杉矶CN2四折

10gbiz怎么样?10gbiz在本站也多次分享过,是一家成立于2020的国人主机商家,主要销售VPS和独立服务器,机房目前有中国香港和美国洛杉矶、硅谷等地,线路都非常不错,香港为三网直连,电信走CN2,洛杉矶线路为三网回程CN2 GIA,10gbiz商家七月连续推出各种优惠活动,除了延续之前的VPS产品4折优惠,目前增加了美国硅谷独立服务器首月半价的活动,有需要的朋友可以看看。10gbiz优惠码...

HostKvm5.95美元起,香港、韩国可选

HostKvm发布了夏季特别促销活动,针对香港国际/韩国机房VPS主机提供7折优惠码,其他机房全场8折,优惠后2GB内存套餐月付仅5.95美元起。这是一家成立于2013年的国外主机服务商,主要提供基于KVM架构的VPS主机,可选数据中心包括日本、新加坡、韩国、美国、中国香港等多个地区机房,均为国内直连或优化线路,延迟较低,适合建站或者远程办公等。下面分享几款香港VPS和韩国VPS的配置和价格信息。...

datepicker为你推荐
骁龙750g和765g哪个好高通骁龙845和骁龙835哪个好滚筒洗衣机和波轮洗衣机哪个好波轮洗衣机和滚桶洗衣机哪个好?哪个更实用?电视直播软件哪个好目前最好的电视直播软件是什么?游戏盒子哪个好请问游戏盒子哪个好啊核芯显卡与独立显卡哪个好核心显卡和独立显卡哪个好dnf魔枪士转职哪个好dnf魔枪士转职哪个适合平民玩oppo和vivo哪个好Vivo和OPPO哪个好点啊?美国国际集团深圳500强企业都有哪些?qq空间登录网页版登录3G版手机QQ空间的网址飞信空间登录怎样在网上登陆飞信
域名劫持 enom 万网优惠券 福建天翼加速 赞助 tna官网 美国网站服务器 香港新世界中心 net空间 域名转入 国外网页代理 重庆服务器 mteam apachetomcat 机柜尺寸 g6950 堡垒主机 海康流媒体服务器 免费邮件服务器软件 台式电脑主机推荐 更多