我正在使用Bootstrap 3 DateTimePicker ,我正在尝试示例 8(链接的 datetimepicker)。
$('#dpStart').datetimepicker({
pickDate: true, //en/disables the date picker
pickTime: false,
format: "DD-MM-YYYY",
useMinutes: false, //en/disables the minutes picker
useSeconds: false
});
$('#dpEnd').datetimepicker({
pickDate: true, //en/disables the date picker
pickTime: false,
format: "DD-MM-YYYY",
useMinutes: false, //en/disables the minutes picker
useSeconds: false
});
$("#dpStart").on("dp.change", function(e) {
alert('hey');
$('#dpEnd').data("DateTimePicker").setMinDate(e.date);
});
$("#dpEnd").on("dp.change", function(e) {
$('#dpStart').data("DateTimePicker").setMaxDate(e.date);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.js"></script>
<script src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
<div class="row">
<div class="col-md-6 col-sm-6 form-group">
<label for="txtStartDate">
Start Date-Time</label>
<div class="input-group date" id="dpStart" data-date-format="DD-MM-YYYY">
<asp:TextBox ID="txtStartDate" runat="server" CssClass="form-control"></asp:TextBox>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="col-md-6 col-sm-6 form-group">
<label for="txtEndDate">
End Date-Time</label>
<div class="input-group date" id="dpEnd" data-date-format="DD-MM-YYYY">
<asp:TextBox ID="txtEndDate" runat="server" CssClass="form-control"></asp:TextBox>
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
日历正在根据需要显示,但 dp.change、dp.hide、dp.show 等事件没有启动。可能是什么问题?有什么帮助吗?
编辑: 请注意,我已经包含了所有必要的文件,如 Bootstrap js、bootstrap css、Moment.js 和 datetimepicker js 和 css 文件。