我想編輯jquery.ui.datepicker中的beforeShowDay函數。 這是在日期選擇器的原 beforeShowDay線,我試圖取代:禁用星期五和星期六在Datepicker
beforeShowDay: null, // Function that takes a date and returns an array with
// [0] = true if selectable, false if not, [1] = custom CSS class
name(s) or '',
// [2] = cell title (optional), e.g. $.datepicker.noWeekends
我有搜索周圍試圖找到正確的代碼,沒有運氣來取代它。 我發現這個小提琴; disable 1 day in datepicker
我已經編輯這個小提琴,併成功地禁用週五和週六用下面的代碼:
$("#datepicker").datepicker({
beforeShowDay: function(date) {
return [date.getDay() == 0 || date.getDay() == 1 || date.getDay() == 2 || date.getDay() == 3 || date.getDay() == 4 ] ;
}
});
然而,當我將其複製並粘貼到jquery.ui.datepicker日曆不起作用,我獲取控制檯錯誤(未捕獲的SyntaxError:意外的令牌)。
我在做什麼用以下替換原 beforeShowDate:
beforeShowDay: function(date) { return [date.getDay() == 0 || date.getDay() == 1 || date.getDay() == 2 || date.getDay() == 3 || date.getDay() == 4 ] ; }
誰能指教一下我做錯了,我怎麼能得到這個正常工作?
你不需要複製粘貼任何東西放入'jquery.ui.datepicker'。總是避免修改從第三方網站下載的jQuery插件。上面的代碼應該進入你自己的html頁面。 – vijayP
嗨vijayP,我試圖把這個代碼放到窗體的html中,但是窗體現在不加載: '' 我不同意關於編輯beforeShowDay的jquery.ui.datepicker,因爲它已經被註釋掉了關於編輯的模糊線索,這意味着有一種編輯方式和 –