我正在使用eonasdan's bootstrap 3 datetimepicker。我只是想知道是否可以使用输入字段以及日历glyphicon打开选择器。
我知道如何使用输入字段或glyphicon打开它,但不能同时打开它们。
HTML如下:
<div class='input-group date'>
<input type='text' class="form-control" id='datetimepicker1'>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<script type="text/javascript">
$('#datetimepicker1').datetimepicker({
format: 'ddd D MMMM, YYYY'
});
</script>
答案 0 :(得分:5)
有一个函数allowInputToggle
可以在点击图标和输入时打开日期选择器,您可以找到here
$(document).ready(function(){
$('#datetimepicker1').datetimepicker({
format: 'ddd D MMMM, YYYY',
allowInputToggle: true
});
});
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<br><br><br>
<div class='col-sm-6'>
<div class="form-group">
<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>
</div>
</div>
&#13;