Parameterization of the maximum value of the jQuery ui slider

I'm trying to create this slider

http://jqueryui.com/demos/slider/#rangemax

Is it possible to parameterize the maximum value?

For ex:

$("#slider-range-max").slider({
            range: "max",
            min: 1,
            max: maxValue,
            value: 2,
            slide: function(event, ui) {
                $("#amount").val(ui.value);
            }
        });

Is it possible to convey a value maxValuewhen I click on something? After initializing it? Not in document ready mode, but even after that?

+3
source share
2 answers

You can set the values ​​at any time, for maxyou do the following:

$("#slider-range-max").slider("option", "max", newValue);

You can see how to do this with all the parameters on the jQuery UI site . Here is an example:

$(".increaseMax").click(function() {
  var currentMax = $("#slider-range-max").slider("option", "max");
  $("#slider-range-max").slider("option", "max", currentMax + 1);
});
+1
source

, ( Options, max):

Get or set the max option, after init. 
  //getter
  var max = $( ".selector" ).slider( "option", "max" );
  //setter
  $( ".selector" ).slider( "option", "max", 7 );

7 /, .

0

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


All Articles