jquery-mobilejquery-mobile-slider

How do I modify the min and max value of a jQueryMobile slider at runtime?


So I have a slider in my HTML document:

<input type="range" name="testSlider" id="testSlider" min="0" max="100" value="0" />

I want to modify the min and max range at run time, but I can't find any documentation on how to do this.

I apologize if this is obvious, but I'm really struggling with this seemingly obvious task. Thanks!


Solution

  • You can use jQuery's .attr() method.

    $('#testSlider').attr('min',MINVALUE);
    $('#testSlider').attr('max',MAXVALUE);
    

    And then you refresh the slider

    $('#testSlider').slider( "refresh" );
    

    OR

    $("#testSlider").slider( "option", { min: MINVALUE, max: MAXVALUE} );