问题
Bootstrap Datetimepicker change event is not firing without errors. Any clue?
https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/docs/Events.md
$('#datetimepickerStart').datetimepicker();
$('#datetimepickerStart').datetimepicker().on('change', function (ev) {
alert('!!!');
});
回答1:
I found the solution
$('#datetimepickerStart').datetimepicker().on('dp.change', function (event) {
alert('!!!');
});
回答2:
<div class="input-group date" id="dateOfBirth" data-target-input="nearest">
<input type="text" class="form-control datetimepicker-input"
data-target="#dateOfBirth" placeholder="Select DOB.." />
<div class="input-group-append" data-target="#dateOfBirth"
data-toggle="datetimepicker">
<div class="input-group-text"> <i class="fa fa-calendar"> </i>
</div>
</div>
</div>
$("#dateOfBirth").on("change.datetimepicker", ({date}) => {
var dob = $("#dateOfBirth").find("input").val();
console.log(dob);
})
This worked for me.
来源:https://stackoverflow.com/questions/38744905/bootstrap-datetimepicker-change-event-is-not-firing