Detect change to selected date with bootstrap-datepicker

前端 未结 7 1550
一整个雨季
一整个雨季 2020-12-01 09:06

I have an input element with an attached datepicker created using bootstrap-datepicker.

7条回答
  •  天涯浪人
    2020-12-01 09:13

    All others answers are related to jQuery UI datepicker, but the question is about bootstrap-datepicker.

    You can use the on changeDate event to trigger a change event on the related input, and then handle both ways of changing the date from the onChange handler:

    changeDate

    Fired when the date is changed.

    Example:

    $('#dp3').datepicker().on('changeDate', function (ev) {
        $('#date-daily').change();
    });
    $('#date-daily').val('0000-00-00');
    $('#date-daily').change(function () {
        console.log($('#date-daily').val());
    });
    

    Here is a working fiddle: http://jsfiddle.net/IrvinDominin/frjhgpn8/

提交回复
热议问题