Dynamically set value of Bootstrap slider?

Nidhish picture Nidhish · Nov 2, 2015 · Viewed 15.5k times · Source

I created a slider as below,

<input id="brightness" onChange="changeBrightness()" data-slider-id='ex1Slider' type="text"
                    data-slider-min="-100" data-slider-max="100" data-slider-step="2" data-slider-value="0"/>

I need to set value dynamically to this slider. I tried,

$("#brightness").slider('setValue', 8, true);
$("#brightness").slider('refresh');

But this is not working. How can I do it?

Answer

user3831200 picture user3831200 · Jan 9, 2017

only $("#brightness").slider('setValue', 8, true);

refresh with initial values $("#brightness").slider('refresh');