单击向上和向下箭头时,Bootstrap 时间选择器变为负值 [英] Bootstrap timepicker goes negative when clicking up and down arrow
问题描述
在 timepicker 的输入字段中,最初我只需要 placeholder
在那里,我决定将 defaultTime
设置为 false:
In the input field of timepicker, initially I just need placeholder
there and I decided to setdefaultTime
as false:
<input type="text" class="timepicker" placeholder="Enter time">
<script>
$('.timepicker').timepicker({
defaultTime:false
});
</script>
但是在将默认时间设置为 false 后,每当我单击向上和向下箭头更改时间时,hour
值变为负值.在文档中,我发现对这个问题没有任何帮助.我如何摆脱负值?任何帮助将不胜感激.
But after setting default time to false, whenever I click up and down arrow for changing time the hour
value goes negative. In the documenation I found nothing helpful for this issue. How do I get rid off that negative values ? Any help would be appreciated.
推荐答案
几周前我遇到了同样的问题,我通过在单击输入字段后将时间设置为 timepicker 来解决该问题:
I was going through same issue couple of weeks ago and I solve the issue by setting time to timepicker just after clicking input field:
$(document).on("click",".timepicker",function(){
var d = new Date();
var current_time = moment(d).format('hh:mm A'); // time format with moment.js
$(this).timepicker('setTime', current_time); // setting timepicker to current time
$(this).val(current_time); // setting input field to current time
});
这篇关于单击向上和向下箭头时,Bootstrap 时间选择器变为负值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!