jQuery UI Slider (setting programmatically)

前端 未结 12 1487
借酒劲吻你
借酒劲吻你 2020-12-02 15:04

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 wil

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 15:43

    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:

    $("#slider").slider('value',50);
    

    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});
    

提交回复
热议问题