gpt4 book ai didi

javascript - jQuery Datepicker Beforeshowday 两个日期数组

转载 作者:行者123 更新时间:2023-12-02 17:55:14 26 4
gpt4 key购买 nike

我有一个数组用于禁用日期,另一个数组用于突出显示日期。有没有办法编码?

例如:

beforeShowDay: function(date){
var unavilble = jQuery.datepicker.formatDate('yy/mm/dd', date);
var newstring = [ arrayable.indexOf(unavilble) == -1 ];
return newstring;
},

第二个数组:

var datet = ['2014/01/19', '2014/01/20'];
//tips are optional but good to have
var tips = ['some description','some other description'];

function highlightDays(date) {
for (var i = 0; i < datet.length; i++) {
if (new Date(datet[i]).toString() == date.toString()) {
return [true, 'highlight', tips[i]];
}
}
return [true, ''];
}
beforeShowDay: highlightDays,

最佳答案

尝试类似的事情

var datet = ['2014/01/19', '2014/01/20'];
//tips are optional but good to have
var tips = ['some description', 'some other description'];
var arrayable = ['2014/01/01', '2014/01/08', '2014/01/15', '2014/01/22', '2014/01/29']
$('input').datepicker({
dateFormat: 'yy/mm/dd',
beforeShowDay: function (date) {
var datestring = jQuery.datepicker.formatDate('yy/mm/dd', date);
var hindex = $.inArray(datestring, datet);
if (hindex > -1) {
return [true, 'highlight', tips[hindex]];
}
var aindex = $.inArray(datestring, arrayable);
return [aindex == -1]
}
})

演示:Fiddle

关于javascript - jQuery Datepicker Beforeshowday 两个日期数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21011110/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com