Set the dynamic value with the jquery range slider

1k Views Asked by At

I'm stuck how to set a dynamic value in range slider. I've used the below code.

<div id="time-range">
    <p><b><?=_('Start Time')?> :</b> <span class="slider-time2"><?= $this->data[0]['horaini']; ?></span>
          <input type="hidden" name="start_time" id="start_time" value="">
    </p>
    <div class="sliders_step1">
        <div id="slider-range"></div>
    </div>
</div>

Jquery code is below

$("#slider-range").slider({
        min: 0,
        max: 1440,
        step: 1,
        slide: function(e, ui) {
            var hours = Math.floor(ui.value / 60);
            var minutes = ui.value - (hours * 60);

            if(hours.toString().length == 1) hours = '0' + hours;
            if(minutes.toString().length == 1) minutes = '0' + minutes;

            $('.slider-time2').html(hours+':'+minutes);
        }
    });

The issue is I want to set dynamic value in slider For Ex:

$("#slider-range").slider("value",20);

But this is not working and slider value can't be change.

0

There are 0 best solutions below