我对“更改时”输入有疑问。它应该做的是单击该按钮时会显示日期选择器,但是当您选择要提交的日期时,输入更改功能将不起作用。请在下面运行代码段。
if (top.location != location) {
top.location.href = document.location.href;
}
$(function() {
window.prettyPrint && prettyPrint();
$('#dp1').datepicker({
format: 'yyyy-mm-dd'
});
$('#dpYears').datepicker();
$('#dpMonths').datepicker();
});
<link href="http://www.eyecon.ro/bootstrap-datepicker/css/bootstrap.css" rel="stylesheet" />
<link href="http://www.eyecon.ro/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://www.eyecon.ro/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<div data-date-format="yyyy-mm-dd">
<form id="date" method="POST" action="index.php">
<input type="text" name="date" class="span2" value="2016-08-07" id="dp1" style="text-align: center; width: 50%; background-color: #5a95f5; border: none;">
</form>
</div>
<script>
$('input[id="dp1"]').change(function() {
$('#date1').submit();
});
</script>
问题是您change()
在选择日期时输入不触发该功能。您可以做的是在datepicker中使用事件,在这种情况下为changeDate
if (top.location != location) {
top.location.href = document.location.href;
}
$(function() {
window.prettyPrint && prettyPrint();
$('#dp1').datepicker({
format: 'yyyy-mm-dd'
});
$('#dpYears').datepicker();
$('#dpMonths').datepicker();
});
<link href="http://www.eyecon.ro/bootstrap-datepicker/css/bootstrap.css" rel="stylesheet" />
<link href="http://www.eyecon.ro/bootstrap-datepicker/css/datepicker.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://www.eyecon.ro/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<div data-date-format="yyyy-mm-dd">
<form id="date" method="POST" action="index.php">
<input type="text" name="date" class="span2" value="2016-08-07" id="dp1" style="text-align: center; width: 50%; background-color: #5a95f5; border: none;">
</form>
</div>
<script>
$('#dp1').on('changeDate', function () {
console.log('Date Selected')
})
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句