我试着打印出日期-时间选择器在 console
但是什么都没有用。
超文本标记语言
<div class="form-group">
<label for="sm" class="control-label col-lg-2 col-sm-4">{{ __('messages.assetmgt.warrantyeffectivedate') }}</label>
<div id="myDate" class="col-sm-6 input-group bootstrap-timepicker">
<input class="input-sm form-control" type="text" name="awEffectiveDateWeb" id="awEffectiveDateWeb" readonly/>
<span class="input-group-addon try dateTimePickerButton" id="awEffectiveDate"><span class="fa fa-calendar"></span></span>
</div
</div>
JS
var value = $("#myDate").datetimepicker("getDate");
console.log(value);
日期时间选择器
$(document).ready(function() {
$('.bootstrap-timepicker').datetimepicker({
format: 'DD/MM/YYYY HH:mm:ss'
});
});
我期望的结果是当DateTime的值被改变时,日期-时间选择器的值会被打印在控制台。
最好在输入元素上初始化数据选择器,而不是在div上初始化。
$('#awEffectiveDateWeb').datetimepicker({
format: 'DD/MM/YYYY HH:mm:ss'
});
而且你可以在更改功能上使用数据选择器。
$('#awEffectiveDateWeb').on('dp.change', function() {
console.log($(this).val());
}