我需要帮助来禁用 jquery 日期选择器上的特定日期。我已成功阻止星期日,但我不知道如何将阻止的日期添加到日历中。我查看了现有的问题和答案,但里面的解决方案不起作用。这是我必须写的脚本。我将非常感谢帮助。我不是程序员。
{{ '//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" defer="defer"></script>
<div style="width:100%; clear:both; margin: 10px 0;">
<p>
<label for="date">CHOOSE A DELIVERY/PICKUP DATE:</label>
<input readonly="readonly" id="date" type="text" name="attributes[date]" value="{{ cart.attributes.date }}" />
</p>
</div>
<script>
window.onload = function() {
if (window.jQuery) {
let $ = window.jQuery;
$(function() {
$("#date").datepicker({
minDate: +2,
maxDate: '+6M',
beforeShowDay: noSundays,
dateFormat: "dd/mm/yy"
});
});
function noSundays(date){
if (date.getDay() === 0) /* Sunday */
return [ false, "", "" ]
else
return [ true, "", "" ]
}
}
}
</script>
blockedDays.push('2023-11-9');