範例:如果想要取消所有週末的日期格子使之不能選取,可以使用 Datepicker 內建的 noWeekends 函式。
$(document).ready(function() {
$(function() {
$('#datepicker_reserve').datepicker({
beforeShowDay: noWeekends
});
});
});
範例:如果想要取消所有週日的日期格子使之不能選取,我們可以將 Datepicker 內建的 noWeekends 函式稍做修改即可。
$(document).ready(function() {
$(function() {
$('#datepicker_reserve').datepicker({
beforeShowDay: noSundays
});
});
});
function noSundays(a) {
a=a.getDay();
return[a>0&&a<7,""];
}
其他參考資訊:
- getDay(): 0= 週日; 6= 週六
- Can the jQuery UI Datepicker be made to disable Saturdays and Sundays (and holidays)? (stackoverflow)
0 Comments:
Post a Comment