jquery ui时间选择器选择当前时间并隐藏今天的时间选择器选择框

时间:2018-04-07 07:47:46

标签: javascript jquery jquery-ui-timepicker

我的输入字段如下 -

<input type="text" maxlength="8" placeholder="" class="time-icn form-control ui-timepicker-input valid" name="ReminderTime" id="ReminderTime" class="ReminderTime" value="" autocomplete="off">

按照以下

添加时间选择器
$("#ReminderTime").timepicker({
  "showDuration": true,
  "timeFormat": "g:i A",
  "step": 15,
  "forceRoundTime": true,
  "maxTime": "11:45pm",
  "className": "timepicker-width",
  "scrollDefault": "now",
});

我到底做了什么?

1 个答案:

答案 0 :(得分:0)

获取date.getHours()和分钟date.getMinutes()的当前小时,然后将其设置为minTime,我删除maxTime以选择今天的剩余时间,而不是{{1} },使用step,您的interval错误。

&#13;
&#13;
timeFormat
&#13;
var date = new Date();
var hour = date.getHours();
var minute = date.getMinutes();

$("#ReminderTime").timepicker({
  "showDuration": true,
  "interval": 15,
  "timeFormat": "h:mm p",
  "forceRoundTime": true,
  "minTime": "" + hour + ":" + minute + "",
  "className": "timepicker-width",
  "scrollDefault": "now",
});
&#13;
&#13;
&#13;