gpt4 book ai didi

jquery - Bootstrap datetimepicker 无法单独打开

转载 作者:行者123 更新时间:2023-12-01 07:05:18 24 4
gpt4 key购买 nike

当我选择并选择第一个日期输入时,第二个日期输入将在与第一个日期输入相同的位置打开日历。看起来这两个日期都是从一个日历中选择的。如何实现日历在每个输入的日期分别打开?

当前:

enter image description here

我想要什么:

enter image description here

HTML:

<form id="filter"> 
<table class="vms">
<tr>
<td><input class="form-control" id="datetimepicker1"></td>
<td><input class="form-control" id="datetimepicker2"></td>
</tr>
</table>
</form>

jQuery:

$('#datetimepicker1').datetimepicker({ format:'YYYY-MM-DD HH:mm', maxDate: $.now(), stepping: 5})
$('#datetimepicker2').datetimepicker({ format:'YYYY-MM-DD HH:mm', maxDate: $.now(), stepping: 5})

我正在使用的日期时间选择器: https://eonasdan.github.io/bootstrap-datetimepicker/

最佳答案

这是一个工作示例,可能对您有帮助

$(function () {
$('#datetimepicker6').datetimepicker();
$('#datetimepicker7').datetimepicker({
useCurrent: false //Important! See issue #1075
});
$("#datetimepicker6").on("dp.change", function (e) {
$('#datetimepicker7').data("DateTimePicker").minDate(e.date);
});
$("#datetimepicker7").on("dp.change", function (e) {
$('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://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>
<link href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/build/css/bootstrap-datetimepicker.css" rel="stylesheet"/>

<script src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/e8bddc60e73c1ec2475f827be36e1957af72e2ea/src/js/bootstrap-datetimepicker.js"></script>
<div class="container">
<div class='col-md-5'>
<div class="form-group">
<div class='input-group date' id='datetimepicker6'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class='col-md-5'>
<div class="form-group">
<div class='input-group date' id='datetimepicker7'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>

关于jquery - Bootstrap datetimepicker 无法单独打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47550371/

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