在Bootstrap日期时间选择器上将日历中的选定日期设置为null

时间:2019-02-05 05:48:18

标签: javascript bootstrap-datetimepicker

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

我正在尝试将所选日期设置为null。我可以在输入字段中保留日期(即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)
        });

}); 

此代码无效。你知道我应该尝试什么吗?

谢谢!

2 个答案:

答案 0 :(得分:-1)

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

进行检查

答案 1 :(得分:-1)

请尝试此操作,他们已明确提及here

工作示例:

$('#datetimepicker4').datetimepicker({ 

       useCurrent: false,//  
 });