gpt4 book ai didi

javascript - 完整日历: start calendar with a specific week

转载 作者:行者123 更新时间:2023-11-28 06:07:56 25 4
gpt4 key购买 nike

我正在使用完整日历,我有一个开始日期,并且我需要日历从与该日期对应的一周开始,我需要隐藏前几周。这是解释我的问题的图片。在此示例中,开始日期是 4 月 20 日。 enter image description here

$(".fc-day").each(function() {  
var startDate = $('#start_date').val();

if (($(this).data('date')) < startDate){
$(this).parents().addClass('hidden');
}

});

我找到了如何删除前几周的解决方案,但我不知道如何用 future 几周替换它们。这是新脚本:

$(".fc-day").each(function() {  

startDate = $('#start_date').val();
var date1 = new Date ($(this).data('date'));
var date2 = new Date (startDate);
var DD = date2.getDate();
var MM = date2.getMonth() + 1;
var YYYY = date2.getFullYear();
var startTraining = YYYY + '-'+ MM + '-'+ DD;
if ((date1 < date2) && (($(this).parent().get(0)) !== ($('.fc-day[data-date="' + startTraining + '"]').parent().get(0)))){
$(this).closest('.fc-row').addClass('hidden');
}
});

最佳答案

Fullcalendar 根据 firstDay 自动渲染日期所在的周。属性,因此除了设置正确的日期之外,您还必须通过调用 getDay()firstDay 属性设置为正确的日期数字。

element.fullCalendar({
defaultDate: startDate,
firstDay: startDate.getDay()
});

关于javascript - 完整日历: start calendar with a specific week,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36656217/

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