Jquery时间选择器禁用时间范围不工作

pu82cl6c  于 2022-12-18  发布在  jQuery
关注(0)|答案(1)|浏览(118)

我正在使用版本1.3.5

<script src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>    
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">

我不知道为什么disableTimeRanges不起作用。我试过这个:

$('.add-costings-starttime').timepicker({
      dynamic: false,
      dropdown: true,
      scrollbar: true,
      'disableTimeRanges': [
      ['1am', '2am'],
      ['3am', '4:01am']
    ]
      change: function (time) {
        var time = $(this).val();
        var picker =   $(this).closest(".costingsRow").find(".add-costings-endtime");
        picker.timepicker('option', 'minTime', time);
    }
    })
rslzwgfq

rslzwgfq1#

$( document ).ready(function() {
    $('input[name="datetime"]').timepicker({
    minTime: '10:00am',
    maxTime: '04:40pm',
    step: 20, // 15 minutes
    disableTimeRanges: [
        ['10:00am', '10:20am'],
        ['4:20pm', '5:00pm']
    ],
    // showDuration: true
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.10.0/jquery.timepicker.min.js"></script>

<input id="timepicker"
       type="text" 
       class = "timepicker"
       name="datetime"
       placeholder = "Time*"
       required/>

相关问题