gpt4 book ai didi

jquery - Bootstrap 日期时间选择器 : show calendar pop-up when a user clicks on input

转载 作者:行者123 更新时间:2023-12-01 00:34:42 24 4
gpt4 key购买 nike

有没有办法在用户点击输入时显示日历?现在我必须单击日历图标,然后它将显示日历。

HTML:

<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>

JavaScript:

$(function() {
$('#datetimepicker1').datetimepicker();
});


示例:https://jsfiddle.net/8jpmkcr5/81/

最佳答案

您可以简单地使用 allowInputToggle选项将其设置为 true(默认值:false)。正如文档所说:

If true, the picker will show on textbox focus and icon click when used in a button group

这是一个实时工作示例:

$('#datetimepicker1').datetimepicker({
allowInputToggle: true
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>

<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>

关于jquery - Bootstrap 日期时间选择器 : show calendar pop-up when a user clicks on input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45371822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com