如何从 bootstrap 日期选择器中获取一个月中未选择的日期
How to get not-selected dates of a month from bootstrap datepicker
我想从 bootstrap datepicker
中获取所有不是 select 的日期
我将select多个日期如下
using :multidate: true
现在我想获取未 select 那个月的日期。
是否有可能得到未 select 一个月的日期?
编辑
$(document).ready(function(){
$ ("#jdate").datepicker({ format: 'dd/mm/yyyy', orientation: 'bottom' , multidate: true}).datepicker('setDate', new Date());
});
使用上面的代码,我会得到 selected 日期。但我不想 selected 日期。
请帮帮我。谢谢!
好吧,在 bootstrap 日期选择器 的整个文档中,没有提及 任何此类方法帮助您实现所需。
因此,作为解决方法,这是我可以想出的办法(虽然我不喜欢这个!):
$('#jdate').datepicker({
multidate: true,
format: 'dd-mm-yyyy',
onSelect: function () {
var allDatesHtml = $('.datepicker-days .day');
var nonSelectedDays = _.compact(_.map(allDatesHtml, function(ele) {
if (!ele.classList.contains('new') && !ele.classList.contains('old') && !ele.classList.contains('active')) {
return ele.textContent;
}
}));
console.log(nonSelectedDays); // gives you all the non selected days of the current month
}
});
Please Note : compact and map used here are Underscore.js functions, which help you ease the code.
如有任何问题/疑问,请随时提出。
我想从 bootstrap datepicker
我将select多个日期如下
using :multidate: true
现在我想获取未 select 那个月的日期。
是否有可能得到未 select 一个月的日期?
编辑
$(document).ready(function(){
$ ("#jdate").datepicker({ format: 'dd/mm/yyyy', orientation: 'bottom' , multidate: true}).datepicker('setDate', new Date());
});
使用上面的代码,我会得到 selected 日期。但我不想 selected 日期。 请帮帮我。谢谢!
好吧,在 bootstrap 日期选择器 的整个文档中,没有提及 任何此类方法帮助您实现所需。
因此,作为解决方法,这是我可以想出的办法(虽然我不喜欢这个!):
$('#jdate').datepicker({
multidate: true,
format: 'dd-mm-yyyy',
onSelect: function () {
var allDatesHtml = $('.datepicker-days .day');
var nonSelectedDays = _.compact(_.map(allDatesHtml, function(ele) {
if (!ele.classList.contains('new') && !ele.classList.contains('old') && !ele.classList.contains('active')) {
return ele.textContent;
}
}));
console.log(nonSelectedDays); // gives you all the non selected days of the current month
}
});
Please Note : compact and map used here are Underscore.js functions, which help you ease the code.
如有任何问题/疑问,请随时提出。