jquery 日期范围 datepicker 格式
我无法弄清楚如何设置日期范围的格式。我是 jquery 新手,我学会了如何设置单个日期选择器,我只是在日期范围方面遇到问题。这是函数
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
I am having trouble figuring out how to set the format for the date range. I am new to jquery and I learned how to set the single datepicker, I am just having trouble with the date range. Here is the function
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我的数据选择器设置功能 - 我发现设置距离当前日期很远的日期很困难,但该控件允许您将月份和年份都转换为下拉列表,因此更容易选择各种范围的日期日期。您可以使用yearRange参数设置年份组合的向前和向后范围。
});
Here's my setup function for the datapicker - I found that it was hard work setting dates that were a long way from the current date but the control allows you to turn both the month and year into dropdowns so it's much easier to select a wide range of dates. You can set the forward and backward range of the year combo with the yearRange parameter.
});
或使用
参考
or use
Reference