JQuery UI slider, error setting values

I have 3 div's

<div id="slider-range1" class="slider-range"></div>
<div id="slider-range2" class="slider-range"></div>
<div id="slider-range3" class="slider-range"></div>

I added a slider to this div using the class link

$(function() {
        $(".slider-range").slider({
            range: true,
            min: 0,
            max: 100,
            slide: function(event, ui) {

            }
        });
});

the ranges of each slider are different. I want to add dynamically

I tried

$("#slider-range1").slider('option','values',[1, 100]);

but it does not work :(

+3
source share
2 answers

You tried:

$('selector').slider( 'values' , index , value ); // index would be the square in the slider

in your example, you could:

$("#slider-range1").slider('values', 0, 50);
$("#slider-range1").slider('values', 1, 100);
+5
source

$('#slider-range').slider('option', 'min', 1);

$('#slider-range').slider('option', 'max', 100);

Updated in accordance with the comment on this comment:

Actually, in your question there is naswer :)

http://jqueryui.com/demos/slider/#option-range

$("#slider-range").slider({
    range: true,
    min: 0,
    max: 500,
    values: [75, 300],
});
+1
source

Source: https://habr.com/ru/post/1729541/


All Articles