首页 > 解决方案 > 在 Bootstrap 日期时间选择器上将日历中的选定日期设置为 null

问题描述

我正在使用引导日期时间选择器,其文档可以在这里找到:https ://eonasdan.github.io/bootstrap-datetimepicker/Options/

我正在尝试将所选日期设置为空。我可以在输入字段中清除日期(即 2/10/2019),但是当我单击输入字段并打开日历时,旧日期仍以蓝色选择。WiThis 是我取消选择日历中所有日期的代码。

 $(document).ready(function() {

    $('.removedate').on('click', function(){

       $("#id_booking_date").val('') //this correctly removes date from input field

       $('.input-group').datetimepicker({
            date: new Date(null)
        });

}); 

此代码不起作用。你知道我应该尝试什么吗?

谢谢!

标签: javascriptbootstrap-datetimepicker

解决方案


您可以尝试为此使用“useCurrent”选项吗?在这里查看https://eonasdan.github.io/bootstrap-datetimepicker/Options/#usecurrent


推荐阅读