http://t1m0n.name/air-datepicker/docs/
我正在使用航空日期选择器日历。如何在日历中突出显示当前星期。看看我的小提琴位置。
<input type="text"
data-range="true"
data-multiple-dates-separator=" - "
data-language="en" id="my-element"
class="datepicker-here"/>
答案 0 :(得分:3)
由于AFAICS Air Datepicker 不会将星期编号添加到单元格data-
中,因此您可以使用脚本获取星期编号(已编辑{{3 }}):
CSS:
.-current-week- {
background: red;
}
JS:
function getWeek(d) {
// https://stackoverflow.com/a/6117889/383904
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay()||7));
var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
var weekNo = Math.ceil(( ( (d - yearStart) / 86400000) + 1)/7);
return {year:d.getUTCFullYear(), number: weekNo};
}
var currentWeekNumber = getWeek(new Date()).number;
$('#my-element').datepicker({
onRenderCell: function(date, cellType) {
if (cellType === 'day' && getWeek(date).number === currentWeekNumber) {
return {
classes: '-current-week-',
}
}
}
});