Jquery TimePicker : How to dynamically change parameters

爷,独闯天下 提交于 2019-11-29 14:06:47

You would do something like this,

$('#startTime').timepicker({
                'minTime': '6:00am',
                'maxTime': '11:30pm',
                    'onSelect': function() {

                    $('#endTime').timepicker('option', 'minTime', $(this).val());                        
              }
            });

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

See this JS Fiddle.

You can go for onchange event:

        $('#startTime').timepicker();

        $('#endTime').timepicker({
            'minTime': '12:00am',
            'showDuration': true
        });

        $('#startTime').on('changeTime', function() {
            $('#endTime').timepicker('option', 'minTime', $(this).val());
        });

I modified the code a bit posted in first reply here is the working fiddle for it http://jsfiddle.net/NXVy2/215/

You can use on('change'... too

    $('#startTime').on('change', function() {
        $('#endTime').timepicker('option', 'minTime', $(this).val());
    });

jQuery-UI widgets generally support an options method that allows you to change the options on an existing instance. Widget methods are called by supplying a string as the first argument to the plugin call:

$(...).widget_name('method_name', arg...)

so this should work for you:

$('#endTime').timepicker('option', 'minTime', new_min_time)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!