答案 0 :(得分:0)
正如ceejayoz在评论中所述,datetimepicker不包含此类功能。该库是开源的,您可以自定义代码和外观。感觉如建议的那样。
另一个方法是在显示选择器时在小时和分钟行下添加一行。您可以向dp.show
事件添加一个列表器,然后使用jQuery来操作选择器HTML。
这是一份工作样本:
$('#datetimepicker1').datetimepicker({
format: 'HH:mm'
});
$('#datetimepicker1').on('dp.show', function(){
// Check timepicker is visible
if( $('.timepicker').is(':visible') ){
// Get rows of the timepicker
var rows = $('.timepicker>.timepicker-picker>table>tbody>tr');
// Create html for custom text
var tr = '<tr class="customText"><td>hours</td><td class="separator"></td><td>minutes</td></tr>';
// Add custom HTML inside component
$(rows[1]).after(tr);
}
});
&#13;
.bootstrap-datetimepicker-widget table tr.customText td {
height: 24px;
line-height: 24px;
}
&#13;
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
&#13;
datetimepicker具有debug
选项,如果设置为true
:
将导致日期选择器在
blur
事件后保持打开状态。