如何将minuteStep动态设置为timepicker
$('#end-time').timepicker({
showInputs: false
minuteStep: 30
});
上面的代码工作正常,但我想动态设置我的开始时间已更改
$('#start-time').on('change', function(){
var minutes_to_add = 45;
$('#end-time').timepicker('minuteStep', minutes_to_add);
});
有什么建议吗?
答案 0 :(得分:0)
您的语法应为
$( "#end-time" ).timepicker('changeTime',{'minuteStep', minutes_to_add});
//Call function on start-time changed
$('#start-time').on('changeTime', function(){
updateDate(45);
});
//Call custom function to apply the new step
function updateDate(minutes_to_add) {
$( "#end-time" ).timepicker('changeTime',{
'minuteStep', minutes_to_add
});
}
或使用onSelect
$('#start-time').timepicker({
'minTime': '6:00am',
'maxTime': '11:30pm',
'onSelect': function() {
$('#end-time').timepicker('option', 'minuteStep', 45);
}
});