javascript - Amsul DateTimePicker - 如何取消选择事件日期?

标签 javascript jquery html css

我正在使用 amsul 日期时间选择器 ( https://amsul.ca/pickadate.js/date/ ),如果您在预览中看到今天的日期以绿色突出显示。现在,如果您将日历移到下个月或上个月。每个月的今天也会突出显示。

我如何取消突出显示除今天以外的任何其他日期?

$('.datepicker').pickadate()
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://hateable-tests.000webhostapp.com/classic.css" rel="stylesheet">
<link href="https://hateable-tests.000webhostapp.com/classic.date.css" rel="stylesheet">
<link href="https://hateable-tests.000webhostapp.com/classic.time.css" rel="stylesheet">
<script src="https://hateable-tests.000webhostapp.com/picker.js"></script>
<script src="https://hateable-tests.000webhostapp.com/legacy.js"></script>
<script src="https://hateable-tests.000webhostapp.com/picker.date.js"></script>
<script src="https://hateable-tests.000webhostapp.com/picker.time.js"></script>
  <input type="text" class="datepicker">

最佳答案

我相信这就是答案:https://github.com/amsul/pickadate.js/issues/805

ilnee commented on 2 Oct 2016

I ran into this issue as well. As a workaround, I remove the picker__day--highlighted class from every div with that class that doesn't have today's timestamp as data-pick value:

var now = new Date();
var timestamp = new Date(now.getFullYear(), now.getMonth(), now.getDate()) / 1;

$('.datepicker').pickadate({
    onRender: function() {
        $('div.picker__day--highlighted').each(function(index, value) {
            if ($(this).data('pick') !== timestamp) {
                $(this).removeClass('picker__day--highlighted');
            }
        });
    }
});

关于javascript - Amsul DateTimePicker - 如何取消选择事件日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56029030/

相关文章:

jquery - 如何从 DataSource 事件处理程序获取 kendoGrid id?

jquery - Bootstrap 4 + 同位素

javascript - 反转带有特殊字符的字符串

html - 单引号和双引号 (' vs ")

javascript - 为什么我无法选择jquery中的元素并更改内容

javascript - 菜单将采用内联样式

javascript - 在传单上绘制 GeoJSON

javascript - 无法更改 jquery 对象 css

html - SVG路径定位

javascript - 当维数可变时如何使用多维数组?