Jquery TimePicker:如何动态更改参数 [英] Jquery TimePicker : How to dynamically change parameters
问题描述
我正在使用Jquery Timepicker。
I am using a Jquery Timepicker .
我有两个输入字段 - 接受时间。
I have two input fields - to Accept times .
<input id="startTime" size="30" type="text" />
<input id="endTime" size="30" type="text" />
我按照文档
$('#startTime').timepicker({
'minTime': '6:00am',
'maxTime': '11:30pm',
'onSelect': function() {
//change the 'minTime parameter of #endTime <--- how do I do this ?
}
});
$('#endTime').timepicker({
'minTime': '2:00pm',
'maxTime': '11:30pm',
'showDuration': true
});
我希望在第一个timePicker被选中时,第二个'minTime'参数会被更改。基本上我正在尝试收集某些活动的开始时间和结束时间。我希望第二个输入框显示第一个输入字段(开始时间)本身的值的选项。
I want that when the first timePicker is selected , the 'minTime' parameter for the second gets changed . Basically I am trying to collect the start time and end time for certain activity . And I want that the second input box shows the options from the value of the first input field (start time ) itself .
推荐答案
你会做这样的事情,
$('#startTime').timepicker({
'minTime': '6:00am',
'maxTime': '11:30pm',
'onSelect': function() {
$('#endTime').timepicker('option', 'minTime', $(this).val());
}
});
你在这里做的是 onSelect
#startTime
的功能,设置 #endTime 的选项
minTime
code>的值为 #startTime
What you are doing here is that in the onSelect
function of the #startTime
, you set the option minTime
of #endTime
to the value of #startTime
请参阅 JS小提琴。
这篇关于Jquery TimePicker:如何动态更改参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!