【问题标题】:Bootstrap timepicker goes negative when clicking up and down arrow单击向上和向下箭头时,引导时间选择器变为负数
【发布时间】:2017-03-26 02:00:27
【问题描述】:

在timepicker的输入字段中,最初我只需要placeholder,我决定将defaultTime设置为false:

<input type="text" class="timepicker" placeholder="Enter time">
<script>
$('.timepicker').timepicker({
    defaultTime:false
 });
</script>

但是在将默认时间设置为 false 之后,每当我单击向上和向下箭头更改时间时,hour 的值就会变为负数。在文档中,我发现对这个问题没有任何帮助。我如何摆脱负面价值观?任何帮助将不胜感激。

【问题讨论】:

    标签: jquery twitter-bootstrap timepicker


    【解决方案1】:

    几周前我遇到了同样的问题,我通过在单击输入字段后将时间设置为 timepicker 来解决问题:

    $(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
    });
    

    【讨论】:

      猜你喜欢
      • 2018-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多