Bootstrap datepicker hide after selection

前端 未结 18 2695
暖寄归人
暖寄归人 2020-12-13 01:30

How do I hide the calendar after a date is selected? Is there a specific function that I can use? My code below:

$(\'#dp1\').datepicker({
    format: \'mm-d         


        
18条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 02:07

    You can use event changedate() to keep track of when the date is changed together with datepicker('hide') method to hide the datepicker after making selection:

    $('yourpickerid').on('changeDate', function(ev){
        $(this).datepicker('hide');
    });
    

    Demo

    UPDATE

    This was the bug with autoclose: true. This bug was fixed in latest master. SEE THE COMMIT. Get the latest code from GitHub

提交回复
热议问题