gpt4 book ai didi

jquery - 需要一个jQuery日历插件,具体日期

转载 作者:行者123 更新时间:2023-12-01 03:56:52 25 4
gpt4 key购买 nike

我需要一个 jQuery 日历插件,我可以在其中指定可选择的日期,但仍会在日历上显示整个月。

最佳答案

使用Datepicker ,只需向检查日期的事件添加处理程序即可。

示例(源自this forum post)

<script type="text/javascript">

$(document).ready(function(){
$("#datepicker").datepicker({
dateFormat: 'dd/mm/yyyy',
beforeShowDay: disableDays
});
});

var disabledDays = ["12/10/2009", "13/10/2009", "15/11/2009"];

function disableDays(date) {

var sDate = date.getDate().toString() + "/" +
(date.getMonth()+1).toString() + "/" +
date.getFullYear().toString();
if ($.inArray(sDate, disabledDays ) != -1) return [true];
else return [false];

}

</script>

另一个示例(更快?)来自 here

$(function() {
// format: specialDays.year.month.day
var specialDays = {
'2009': {
'1': {'1': {tooltip: "New Year's Day", className: "holiday"}},
'4': {
'10': {tooltip: "Good Friday", className: "holiday"},
'13': {tooltip: "Easter Monday", className: "holiday"}
},
'5': {
'4': {tooltip: "Early May Bank Holiday", className: "holiday"},
'15': {tooltip: "Spring Bank Holiday", className: "holiday"}
},
'8': {'31': {tooltip: "Summer Bank Holiday", className: "holiday"}},
'12': {
'25': {tooltip: "Christmas Day", className: "holiday"},
'28': {tooltip: "Boxing Day", className: "holiday"}
}
}
};

$('#datepicker').datepicker({beforeShowDay: function(date) {
var d = date.getDate(),
m = date.getMonth()+1,
y = date.getFullYear();

if (specialDays[y] && specialDays[y][m] && specialDays[y][m][d]) {
var s = specialDays[y][m][d];
return [true, s.className, s.tooltip]; // selectable
}
return [false,'']; // non-selectable
}});
});

关于jquery - 需要一个jQuery日历插件,具体日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1484191/

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