jAndy jAndy - 2 years ago 154
Javascript Question

jQuery UI Slider (setting programatically)

I'd like to modify the sliders on-the-fly. I tried to do so by using

$("#slider").slider("option", "values", [50,80]);

This call will set the values, but the element will not update the slider positions.


does not help either.

Is there another/better way to modify the value AND slider position ?

Answer Source

It depends on if you want to change the sliders in the current range or change the range of the sliders.

If it is the values in the current range you want to change, then the .slider() method is the one you should use, but the syntax is a bit different than you used:


or if you have a slider with two handles it would be:

$("#slider").slider('values',0,50); // sets first handle (index 0) to 50
$("#slider").slider('values',1,80); // sets second handle (index 1) to 80

If it is the range you want to change it would be:

$("#slider").slider('option',{min: 0, max: 500});
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download