jquery中的Datepicker控件如何默认显示日期
16lz
2021-01-22
Datepicker控件完成加载后,输入框显示为空
如何在这里显示当天的日期呢,用javascript语句是可以做到
但我想知道通过设置Datepicker的属性能不能达到相同的功能
Setthedatetohighlightonfirstopeningifthefieldisblank.SpecifyeitheranactualdateviaaDateobjectorasastringinthecurrentdateFormat,oranumberofdaysfromtoday(e.g.+7)orastringofvaluesandperiods('y'foryears,'m'formonths,'w'forweeks,'d'fordays,e.g.'+1m+7d'),ornullfortoday.
Codeexamples
InitializeadatepickerwiththedefaultDateoptionspecified.
$(".selector").datepicker({defaultDate:+7});
GetorsetthedefaultDateoption,afterinit.
//getter
vardefaultDate=$(".selector").datepicker("option","defaultDate");
//setter
$(".selector").datepicker("option","defaultDate",+7);
如何在这里显示当天的日期呢,用javascript语句是可以做到
但我想知道通过设置Datepicker的属性能不能达到相同的功能
4 个解决方案
#1
Setthedatetohighlightonfirstopeningifthefieldisblank.SpecifyeitheranactualdateviaaDateobjectorasastringinthecurrentdateFormat,oranumberofdaysfromtoday(e.g.+7)orastringofvaluesandperiods('y'foryears,'m'formonths,'w'forweeks,'d'fordays,e.g.'+1m+7d'),ornullfortoday.
Codeexamples
InitializeadatepickerwiththedefaultDateoptionspecified.
$(".selector").datepicker({defaultDate:+7});
GetorsetthedefaultDateoption,afterinit.
//getter
vardefaultDate=$(".selector").datepicker("option","defaultDate");
//setter
$(".selector").datepicker("option","defaultDate",+7);
更多相关文章
- 发布一个基于jquery的无限层级下拉控件
- JQUERY中做表单验证,谁有带时间的日期选择控件?
- Jquery注册服务器控件事件与判断控件的值
- Jquery如何获取下一个控件的ID?
- JS和JQuery中如何获取和修改控件显示内容(如lable,div,h1)
- html中插入activex控件之后 需要在 网页中实现控件的属性及方法,
- Html5的datetime-local控件
- ASP.NET按部分ID查找控件
- 如何用c#获取服务器端元素的innerhtml(内部有另一个服务器端控件)